Skip to content

/AWS1/CL_EC2=>CREATEREPLACEROOTVOLUMETASK()

About CreateReplaceRootVolumeTask

Replaces the EBS-backed root volume for a running instance with a new volume that is restored to the original root volume's launch state, that is restored to a specific snapshot taken from the original root volume, or that is restored from an AMI that has the same key characteristics as that of the instance.

For more information, see Replace a root volume in the Amazon EC2 User Guide.

Method Signature

IMPORTING

Required arguments:

iv_instanceid TYPE /AWS1/EC2INSTANCEID /AWS1/EC2INSTANCEID

The ID of the instance for which to replace the root volume.

Optional arguments:

iv_snapshotid TYPE /AWS1/EC2SNAPSHOTID /AWS1/EC2SNAPSHOTID

The ID of the snapshot from which to restore the replacement root volume. The specified snapshot must be a snapshot that you previously created from the original root volume.

If you want to restore the replacement root volume to the initial launch state, or if you want to restore the replacement root volume from an AMI, omit this parameter.

iv_clienttoken TYPE /AWS1/EC2STRING /AWS1/EC2STRING

Unique, case-sensitive identifier you provide to ensure the idempotency of the request. If you do not specify a client token, a randomly generated token is used for the request to ensure idempotency. For more information, see Ensuring idempotency.

iv_dryrun TYPE /AWS1/EC2BOOLEAN /AWS1/EC2BOOLEAN

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

it_tagspecifications TYPE /AWS1/CL_EC2TAGSPECIFICATION=>TT_TAGSPECIFICATIONLIST TT_TAGSPECIFICATIONLIST

The tags to apply to the root volume replacement task.

iv_imageid TYPE /AWS1/EC2IMAGEID /AWS1/EC2IMAGEID

The ID of the AMI to use to restore the root volume. The specified AMI must have the same product code, billing information, architecture type, and virtualization type as that of the instance.

If you want to restore the replacement volume from a specific snapshot, or if you want to restore it to its launch state, omit this parameter.

iv_deletereplacedrootvolume TYPE /AWS1/EC2BOOLEAN /AWS1/EC2BOOLEAN

Indicates whether to automatically delete the original root volume after the root volume replacement task completes. To delete the original root volume, specify true. If you choose to keep the original root volume after the replacement task completes, you must manually delete it when you no longer need it.

iv_volumeinitializationrate TYPE /AWS1/EC2LONG /AWS1/EC2LONG

Specifies the Amazon EBS Provisioned Rate for Volume Initialization (volume initialization rate), in MiB/s, at which to download the snapshot blocks from Amazon S3 to the replacement root volume. This is also known as volume initialization. Specifying a volume initialization rate ensures that the volume is initialized at a predictable and consistent rate after creation.

Omit this parameter if:

  • You want to create the volume using fast snapshot restore. You must specify a snapshot that is enabled for fast snapshot restore. In this case, the volume is fully initialized at creation.

    If you specify a snapshot that is enabled for fast snapshot restore and a volume initialization rate, the volume will be initialized at the specified rate instead of fast snapshot restore.

  • You want to create a volume that is initialized at the default rate.

For more information, see Initialize Amazon EBS volumes in the Amazon EC2 User Guide.

Valid range: 100 - 300 MiB/s

RETURNING

oo_output TYPE REF TO /aws1/cl_ec2crerplrootvoltskrs /AWS1/CL_EC2CRERPLROOTVOLTSKRS

Domain /AWS1/RT_ACCOUNT_ID
Primitive Type NUMC

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->/aws1/if_ec2~createreplacerootvolumetask(
  it_tagspecifications = VALUE /aws1/cl_ec2tagspecification=>tt_tagspecificationlist(
    (
      new /aws1/cl_ec2tagspecification(
        it_tags = VALUE /aws1/cl_ec2tag=>tt_taglist(
          (
            new /aws1/cl_ec2tag(
              iv_key = |string|
              iv_value = |string|
            )
          )
        )
        iv_resourcetype = |string|
      )
    )
  )
  iv_clienttoken = |string|
  iv_deletereplacedrootvolume = ABAP_TRUE
  iv_dryrun = ABAP_TRUE
  iv_imageid = |string|
  iv_instanceid = |string|
  iv_snapshotid = |string|
  iv_volumeinitializationrate = 123
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lo_replacerootvolumetask = lo_result->get_replacerootvolumetask( ).
  IF lo_replacerootvolumetask IS NOT INITIAL.
    lv_replacerootvolumetaskid = lo_replacerootvolumetask->get_replacerootvolumetaskid( ).
    lv_string = lo_replacerootvolumetask->get_instanceid( ).
    lv_replacerootvolumetaskst = lo_replacerootvolumetask->get_taskstate( ).
    lv_string = lo_replacerootvolumetask->get_starttime( ).
    lv_string = lo_replacerootvolumetask->get_completetime( ).
    LOOP AT lo_replacerootvolumetask->get_tags( ) into lo_row.
      lo_row_1 = lo_row.
      IF lo_row_1 IS NOT INITIAL.
        lv_string = lo_row_1->get_key( ).
        lv_string = lo_row_1->get_value( ).
      ENDIF.
    ENDLOOP.
    lv_imageid = lo_replacerootvolumetask->get_imageid( ).
    lv_snapshotid = lo_replacerootvolumetask->get_snapshotid( ).
    lv_boolean = lo_replacerootvolumetask->get_deletereplacedrootvolume( ).
  ENDIF.
ENDIF.