@SdkInternalApi
    final AttachVolumeResult executeAttachVolume(AttachVolumeRequest attachVolumeRequest) {

        ExecutionContext executionContext = createExecutionContext(attachVolumeRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<AttachVolumeRequest> request = null;
        Response<AttachVolumeResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new AttachVolumeRequestMarshaller().marshall(super.beforeMarshalling(attachVolumeRequest));
                // Binds the request metrics to the current request.
                request.setAWSRequestMetrics(awsRequestMetrics);
                request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
                request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
                request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
                request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EC2");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "AttachVolume");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

            } finally {
                awsRequestMetrics.endEvent(Field.RequestMarshallTime);
            }

            StaxResponseHandler<AttachVolumeResult> responseHandler = new StaxResponseHandler<AttachVolumeResult>(new AttachVolumeResultStaxUnmarshaller());

            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<p>
Attaches an EBS volume to a running or stopped instance and exposes it to the instance with the specified device
name.
</p>
<p>
Encrypted EBS volumes must be attached to instances that support Amazon EBS encryption. For more information, see
<a href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-encryption.html">Amazon EBS encryption</a> in the
<i>Amazon EBS User Guide</i>.
</p>
<p>
After you attach an EBS volume, you must make it available. For more information, see <a
href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-using-volumes.html">Make an EBS volume available for
use</a>.
</p>
<p>
If a volume has an Amazon Web Services Marketplace product code:
</p>
<ul>
<li>
<p>
The volume can be attached only to a stopped instance.
</p>
</li>
<li>
<p>
Amazon Web Services Marketplace product codes are copied from the volume to the instance.
</p>
</li>
<li>
<p>
You must be subscribed to the product.
</p>
</li>
<li>
<p>
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.
</p>
</li>
</ul>
<p>
For more information, see <a
href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-attaching-volume.html">Attach an Amazon EBS volume to
an instance</a> in the <i>Amazon EBS User Guide</i>.
</p>

@param attachVolumeRequest
@return Result of the AttachVolume operation returned by the service.
@sample AmazonEC2.AttachVolume
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/AttachVolume" target="_top">AWS API
     Documentation</a>
aws-java-sdk-ec2/src/main/java/com/amazonaws/services/ec2/AmazonEC2Client.java