/AWS1/CL_EC2=>ATTACHVOLUME()
¶
About AttachVolume¶
Attaches an Amazon EBS volume to a running
or stopped
instance, and exposes it to the instance with the specified device name.
The maximum number of Amazon EBS volumes that you can attach to an instance depends on the
instance type. If you exceed the volume attachment limit for an instance type, the attachment
request fails with the AttachmentLimitExceeded
error. For more information,
see Instance
volume limits.
After you attach an EBS volume, you must make it available for use. For more information, see Make an EBS volume available for use.
If a volume has an Amazon Web Services Marketplace product code:
-
The volume can be attached only to a stopped instance.
-
Amazon Web Services Marketplace product codes are copied from the volume to the instance.
-
You must be subscribed to the product.
-
The instance type and operating system of the instance must support the product. For example, you can't detach a volume from a Windows instance and attach it to a Linux instance.
For more information, see Attach an Amazon EBS volume to an instance in the Amazon EBS User Guide.
Method Signature¶
IMPORTING¶
Required arguments:¶
iv_device
TYPE /AWS1/EC2STRING
/AWS1/EC2STRING
¶
The device name (for example,
/dev/sdh
orxvdh
).
iv_instanceid
TYPE /AWS1/EC2INSTANCEID
/AWS1/EC2INSTANCEID
¶
The ID of the instance.
iv_volumeid
TYPE /AWS1/EC2VOLUMEID
/AWS1/EC2VOLUMEID
¶
The ID of the EBS volume. The volume and instance must be within the same Availability Zone.
Optional arguments:¶
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 isUnauthorizedOperation
.
RETURNING¶
oo_output
TYPE REF TO /aws1/cl_ec2volumeattachment
/AWS1/CL_EC2VOLUMEATTACHMENT
¶
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~attachvolume(
iv_device = |string|
iv_dryrun = ABAP_TRUE
iv_instanceid = |string|
iv_volumeid = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_boolean = lo_result->get_deleteontermination( ).
lv_string = lo_result->get_associatedresource( ).
lv_string = lo_result->get_instanceowningservice( ).
lv_string = lo_result->get_volumeid( ).
lv_string = lo_result->get_instanceid( ).
lv_string = lo_result->get_device( ).
lv_volumeattachmentstate = lo_result->get_state( ).
lv_datetime = lo_result->get_attachtime( ).
ENDIF.
To attach a volume to an instance¶
This example attaches a volume (vol-1234567890abcdef0
) to an instance (i-01474ef662b89480
) as /dev/sdf
.
DATA(lo_result) = lo_client->/aws1/if_ec2~attachvolume(
iv_device = |/dev/sdf|
iv_instanceid = |i-01474ef662b89480|
iv_volumeid = |vol-1234567890abcdef0|
).