How can I multiattach EBS volumes to more than one EC2 instance?
Solution 1:
You cannot do this. The EC2 API does not allow for it.
Solution 2:
Now you can do it with Provisioned IOPS io1 volumes.
AWS Announcement:
You can now enable Multi-Attach on Amazon EBS Provisioned IOPS io1 volumes to allow a single volume to be concurrently attached to up to sixteen AWS Nitro System-based Amazon Elastic Compute Cloud (Amazon EC2) instances within the same Availability Zone.
Note that it's necessary to use file systems designed for multi-writing or replication like GFS2 or OCFS2.
Solution 3:
If you want to do this, use Elastic File System (EFS) rather than Elastic Block Storage (EBS).
https://aws.amazon.com/efs/
Notes:
- It is much slower with small files
Solution 4:
EBS is for a single instance only. Sharing an EBS instance would be like putting the same physical disk in two machines.
If you want two instances of the disk you can create an EBS snapshot or an AMI based on that EBS disk. This would let you run multiple instances of a web server, for example.
If you really want shared storage for data look at Amazon EFS, or you could use S3.