-1

Question in title. Just wondering how this works: if you have an EC2 instance which serves some code (let's call it a simple web server), how is this code copied to the other EC2 instances if they are launched as part of the Auto-Scaling Group? I believe you can copy the AMI which has the operating system and perhaps some installations, but does it also have the files that are served?

Kind regards

beyondtdr
  • 411
  • 6
  • 17
  • An instance launched from an AMI has whatever files the donor instance had when you created the AMI. You need to decide how up to date you want to keep your AMI vs. how much bootstrapping you want to do at launch time. A good place to start may be https://aws.amazon.com/devops/ – jarmod Nov 11 '20 at 18:21

1 Answers1

1

If the files being served are part of the AMI yes. Otherwise now.

Basically an AMI is something in a form of a snapshot. Whatever was there when you created it will be on the new instance.

But if that's not the case you have several options to duplicate files across instances in auto scaling group:

  1. Execute your own code upon instance start as part of something called "user data". There you could download the files you want to serve. Obviously they may run out of sync between instances.

  2. Mount an additional EBS or EFS volume that will contain the files you want to serve.

  3. Serve file loaded from S3

Aleksander Wons
  • 3,611
  • 18
  • 29