I want to attach my Amazon Elastic Block Store (EBS) volume to my Amazon Elastic Compute Cloud (Amazon EC2) instance, but it fails.
Resolution
Your Amazon EC2 instance and Amazon EBS volume are in different Availability Zones
EBS volumes are specific to the Availability Zone that you create them in. Make sure that the instance that you want to attach your volume to is in the same Availability Zone. To determine the Availability Zones that are available for your AWS account, see AWS Availability Zones. To check the Availability Zone that your volume is in, see View information about an Amazon EBS volume.
The device name that you specified is already in use
When you attach a volume to an instance, you provide a device name for the volume that EC2 uses. You can't use duplicate device names. If the device name is already in use, then the operation fails with the error message: "Invalid value '/dev/abc' for unixDevice. Attachment point /dev/abc is already in use".
To resolve this issue, choose a different device name. For more information, see Device names for volumes on Amazon EC2 instances.
If you forcefully detach a volume from an EC2 instance, then the block device driver might continue to use the device name. Then, you can't use the device name for the volume, and you must choose a different device name or reboot the instance.
For more information, see Detach an Amazon EBS volume from an Amazon EC2 instance.
Either the volume or the instance is in an incorrect operating state
You can attach a volume to an instance only when the instance is in the running or stopped state. You can't attach a volume when the instance is in the pending or stopping state. Also, the volume must be in the available state when you attach it to the instance.
If the volume is stuck in the attaching state, then see Why is my EBS volume stuck in the attaching state?
EC2 reached the maximum instance volume quota
The maximum number of volumes that an instance supports depends on the type of instance and operating system (OS). If your volume attachment fails and you don't receive an error message, then check the instance volume quotas.
The volume has an AWS Marketplace product code
If your volume has an AWS Marketplace product code, then you must subscribe to the AWS Marketplace code that's on the volume. Also, the instance configuration must adhere to that AWS Marketplace code's requirements. For more information, see Attach an Amazon EBS volume to an Amazon EC2 instance.
Your IAM user or role doesn't have the permission to perform the AttachVolume action
To use the AttachVolume API to attach an EBS volume to an instance, your AWS Identity and Access Management (IAM) user or role might must have permission to perform the AttachVolume API action. If you don't have permission, or an AWS Organizations service control policy (SCP) is restricting your IAM user or role, then you receive the following error message:
"You are not authorized to perform this operation. Encoded authorization failure message..."
To resolve the issue, see How can I troubleshoot access denied or unauthorized operation errors with an IAM policy?