I'm running an application on AWS Elastic Beanstalk, and it looks like I need to create a new environment if I want to use the latest AMI.
If I knew what the latest AMI id was, I could update it in the environment configuration.
Is there a place where I could find the ID of the latest Elastic Beanstalk AMIs, or even better, is it possible to have the instances automatically replaced by the new version whenever a new version is rolled out?
The recommended and supported way to upgrade your AWS Beanstalk environment is documented here and managed platform updates are discussed here, honestly I'd stick to that if you want things to be easy (and that's what Beanstalk is all about), you'll theoretically only get the non-breaking updates and AWS will manage the process so there's no downtime.
So I just want to reiterate that managed platform updates are probably what you or anyone else coming here from Google will want, but if you want to know the latest AWS provided AMI for your Beanstalk environment it can be done fairly trivially with AWS CLI (thanks to sane naming conventions from Amazon on their AMIs).
Starting with an instance from your environment, describe the instance to get the current AMI (skip if you already know the current AMI).
Take the resulting AMI ID and describe it.
We can use the output of the above as input to a new, sorted
describe-images
but this time we replace the timestamps with*
wildcard symbols, like so:Due to the power of lexical sorting and ISO 8601, we end up with the latest AMI, which in my example is
ami-1be5de78
.Again, I wouldn't recommend you try to change to this AMI by hand, Beanstalk has provisions to do all this for you!
It seems like even if you change the AMI, to a proper AMI ElasticBeanstalk uses. It doesn't seem to work properly. It misses all of the files. It doesn't work right.
I think you have to start a new Elastic Beanstalk environment that has the updated AMI. Make everything work then swap the environment urls.
You could use the managed updates features that comes with eb but will have to pay for enhanced health reporting to do this. Or use the 'eb platform show' command; In a worker app have a cron that runs CURRENT=
eb platform show your_env_name | sed -n '5p' | cut -d: -f2- | tr -d '[[:space:]]'
LATEST=eb platform show your_env_name | sed -n '6p' | cut -d: -f2- | tr -d '[[:space:]]'
- Then compare them and if different you can use eb clone (defaults to new version) and then cname swap.Navigating to the dashboard of your application locate 'Configuration' and click 'Change'
You should see a list where you can choose a Platform. The latest version is indicated in that list. Selecting platform
AWS EB uses specific setups for different programming languages. You can find a list of the setups in the documentation http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html
There are tables showing you which AMI version each platform uses.
I didn't find a way to run these updates automatically though. I actually prefer to review changes of the platform and test them before deploying them.
Select your service in Elastic Beanstalk, You will see overview in Dashboard, In the dashboard right hand side you can see configuration of your AMI, Select Change upgrade or degrade your AMI. At this point your are going to replace your instance. So make the backup or clone.
I was able to update my current application hosted on Beanstalk to the latest Amazon Linux AMI using the steps below.
1- Log into the AWS Console and navigate into the Beanstalk portal.
2- Navigate into the configuration page of your application and click-on 'Instances'.
3- Locate the AMI id it should be like so AMI-xxxxxx.
4- Take the AMI id and navigate back into the EC2 console and click-on AMI.
5- Change the view to Public Images and look for the AMI id retrieve earlier from the Beanstalk configuration.
6- Launch that AMI as a new instance.
7- Once its launched log into the instance and customize as per your applications requirements.
8- Once your satisfied everything in place as you would like it to be create an AMI image of this new instance.
9- Take the new instance AMI id that was created in step 8 and apply that to your Beanstalk application configuration.
10- It will not delete the old instance and create the new instance with your customize AMI and also deploy your latest application onto the new instances.