2 Answers
- Newest
- Most votes
- Most comments
3
More information about your specific use case would be helpful, but something I have used in this scenario is an EFS filesystem which is mounted on all EC2 instances which are provisioned from the launch template.
In the user data just echo
a row into /etc/fstab
and then mount -a
, and the new instance has a view of the same data as the existing instance(s).
But like I said at the start, your use case means this might not be practical.
1
Hi, an alternative to EFS is to use Amazon EBS Multi-Attach volumes that you can attach simultaneously to several EC2 instances. It may be a bit simpler to manage than EFS
See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes-multi.html
Best,
Didier
I want to use this in autoscaling group not manual
Relevant content
- Accepted Answerasked a year ago
- asked 5 months ago
- asked 5 years ago
- AWS OFFICIALUpdated 10 months ago
- I can't use Amazon EC2 Auto Scaling to launch EC2 instances with encrypted AMIs or encrypted volumesAWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated a year ago
please suggest userdata script for this
Here's an example, you need to put the actual IP (or DNS name) for the EFS mountpoint in place of the terraform resource that I used in my code, as well as having an EFS filesystem and mountpoint(s) already created:
About 1 time in 20 I found that the EFS filesystem wouldn't mount when the instance was provisioned, the while loop is to guard against this and re-try if it happens.