Why can't I attach my Amazon EBS volume to my EC2 instance?
When I try to attach my Amazon Elastic Block Store (EBS) volume to my Amazon Elastic Compute Cloud (Amazon EC2) instance it fails. How do I resolve the issue?
"When I try to attach my Amazon Elastic Block Store (EBS) volume to my Amazon Elastic Compute Cloud (Amazon EC2) instance it fails. How do I resolve the issue?Short descriptionThere following are common reasons why attaching an Amazon EBS volume to your Amazon EC2 instance fails:Your EC2 instance and EBS volume are in different Availability Zones.The device name that you specified is already in use.Either the volume or the instance is in the incorrect operating state.The volume type is io2 Block Express.Amazon EC2 reached the maximum instance volume limit.The volume has an AWS Marketplace product code.Your AWS Identity and Access Management (IAM) user or role doesn't have the permission to perform the AttachVolume action.ResolutionYour EC2 instance and EBS volume are in different Availability ZonesEBS volumes are specific to the Availability Zone that you create them in. Make sure that the instance that you're attaching your volume to is in the same Availability Zone. To determine the Availability Zones that are available for your AWS account, see Describe your 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 useWhen you attach a volume to an instance, you provide a device name for the volume that Amazon EC2 uses. Amazon EC2 doesn't allow you to use duplicate device names. The operation fails with the following error: Invalid value '/dev/xxx' for unixDevice. Attachment point /dev/xxx is already in use.If the device name is already in use, then you must choose a different device name. For more details on device naming, see Device names on Linux instances or Device names on Windows instances.Sometimes, if a volume is forcefully detached from an EC2 instance, then the block device driver might still be using the device name. Therefore, you can't use the device name for that volume. You must choose a different device name, or reboot the instance.For more information, see Detach an Amazon EBS volume from a Linux instance.Either the volume or the instance is in the incorrect operating stateYou 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 "starting" 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 Amazon EBS volume stuck in the "attaching" state?The volume type is io2 Block ExpressYou can attach an io2 Block Express volume only to the following instance types: c7g, r5b, trn1, x2idn, and x2iedn. If you try to attach an io2 Block Express volume to any other instance type, then you get the following error: "vol-xxxxxxxx is already attached to an instance."For more information, see io2 Block Express volumes.Amazon EC2 reached the maximum instance volume limitThe maximum number of volumes that an instance supports depends on the type of instance and operating system. If your volume attachment fails and you don't receive an error message, then check the instance volume limits.The volume has an AWS Marketplace product codeIf 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, go to Attach an Amazon EBS volume to an instance, and see the Prerequisites.Your IAM user or role doesn't have the permission to perform the AttachVolume actionYou receive the following error: "You are not authorized to perform this operation. Encoded authorization failure message..."Amazon EC2 uses the AttachVolume API to attach an EBS volume to an instance. Your IAM user or role might not have the IAM policy permission to perform the AttachVolume API action. Or, an AWS Organizations service control policy (SCP) might be restricting your IAM user or role. To resolve this issue, see How can I troubleshoot access denied or unauthorized operation errors with an IAM policy?Follow"