Skip to content

/AWS1/CL_EC2=>CREATESNAPSHOTS()

About CreateSnapshots

Creates crash-consistent snapshots of multiple EBS volumes attached to an Amazon EC2 instance. Volumes are chosen by specifying an instance. Each volume attached to the specified instance will produce one snapshot that is crash-consistent across the instance. You can include all of the volumes currently attached to the instance, or you can exclude the root volume or specific data (non-root) volumes from the multi-volume snapshot set.

The location of the source instance determines where you can create the snapshots.

  • If the source instance is in a Region, you must create the snapshots in the same Region as the instance.

  • If the source instance is in a Local Zone, you can create the snapshots in the same Local Zone or in its parent Amazon Web Services Region.

  • If the source instance is on an Outpost, you can create the snapshots on the same Outpost or in its parent Amazon Web Services Region.

Method Signature

IMPORTING

Required arguments:

io_instancespecification TYPE REF TO /AWS1/CL_EC2INSTANCESPEC /AWS1/CL_EC2INSTANCESPEC

The instance to specify which volumes should be included in the snapshots.

Optional arguments:

iv_description TYPE /AWS1/EC2STRING /AWS1/EC2STRING

A description propagated to every snapshot specified by the instance.

iv_outpostarn TYPE /AWS1/EC2STRING /AWS1/EC2STRING

Only supported for instances on Outposts. If the source instance is not on an Outpost, omit this parameter.

  • To create the snapshots on the same Outpost as the source instance, specify the ARN of that Outpost. The snapshots must be created on the same Outpost as the instance.

  • To create the snapshots in the parent Region of the Outpost, omit this parameter.

For more information, see Create local snapshots from volumes on an Outpost in the Amazon EBS User Guide.

it_tagspecifications TYPE /AWS1/CL_EC2TAGSPECIFICATION=>TT_TAGSPECIFICATIONLIST TT_TAGSPECIFICATIONLIST

Tags to apply to every snapshot specified by the instance.

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.

iv_copytagsfromsource TYPE /AWS1/EC2COPYTAGSFROMSOURCE /AWS1/EC2COPYTAGSFROMSOURCE

Copies the tags from the specified volume to corresponding snapshot.

iv_location TYPE /AWS1/EC2SNAPSHOTLOCATIONENUM /AWS1/EC2SNAPSHOTLOCATIONENUM

Only supported for instances in Local Zones. If the source instance is not in a Local Zone, omit this parameter.

  • To create local snapshots in the same Local Zone as the source instance, specify local.

  • To create a regional snapshots in the parent Region of the Local Zone, specify regional or omit this parameter.

Default value: regional

RETURNING

oo_output TYPE REF TO /aws1/cl_ec2createsnapsresult /AWS1/CL_EC2CREATESNAPSRESULT

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~createsnapshots(
  io_instancespecification = new /aws1/cl_ec2instancespec(
    it_excludedatavolumeids = VALUE /aws1/cl_ec2volidstringlist_w=>tt_volumeidstringlist(
      ( new /aws1/cl_ec2volidstringlist_w( |string| ) )
    )
    iv_excludebootvolume = ABAP_TRUE
    iv_instanceid = |string|
  )
  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_copytagsfromsource = |string|
  iv_description = |string|
  iv_dryrun = ABAP_TRUE
  iv_location = |string|
  iv_outpostarn = |string|
).

This is an example of reading all possible response values

LOOP AT lo_result->get_snapshots( ) into lo_row.
  lv_string = lo_row_1->get_description( ).
  LOOP AT lo_row_1->get_tags( ) into lo_row_2.
    lv_string = lo_row_3->get_key( ).
    lv_string = lo_row_3->get_value( ).
  ENDLOOP.
  lv_boolean = lo_row_1->get_encrypted( ).
  lv_string = lo_row_1->get_volumeid( ).
  lv_snapshotstate = lo_row_1->get_state( ).
  lv_integer = lo_row_1->get_volumesize( ).
  lv_milliseconddatetime = lo_row_1->get_starttime( ).
  lv_string = lo_row_1->get_progress( ).
  lv_string = lo_row_1->get_ownerid( ).
  lv_string = lo_row_1->get_snapshotid( ).
  lv_string = lo_row_1->get_outpostarn( ).
  lv_ssetype = lo_row_1->get_ssetype( ).
  lv_string = lo_row_1->get_availabilityzone( ).
ENDLOOP.