0

My java application is configured on an AMI image (so that I can use Auto Scaling Groups). I want to have the ability to update the app, and as existing AMIs cannot be updated, I would set my launch config to start an external jar file - hosted on S3 - which I can update whenever I wish.

Is it possible to load a jar file from an S3 bucket?

java -jar app.jar

1 Answers1

0

You could have the ec2 use a cloud-init script run the "aws S3 sync" command (r similar) to update the jar file on server startup. That runs before the services get started, so when it starts it'll be the latest version.

You can also run things like "sudo yum update -y" (from memory) to update the OS and packages from cloud-init before the software starts.

Tim
  • 30,383
  • 6
  • 47
  • 77
  • About the update: Isn't it bad practice to execute time consuming operations in the launch script? Auto Scaling would react slowly on demand changes. – nagy.zsolt.hun Dec 21 '18 at 10:12
  • In general you're correct, do as little as possible in your startup script. However, if you update your AMI every (say) month the number of updates should be small and the time minimal. I run yum update on a t2.nano every week or so, it takes 5 - 20 seconds typically. You could also run just security updates. – Tim Dec 21 '18 at 17:30