18

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?

BenMorel
  • 4,215
  • 10
  • 53
  • 81
  • 2
    Fire up a new environment and see what the AMI ID is on the server it launches? – ceejayoz Apr 01 '13 at 16:45
  • 2
    That's a bit of a pain, isn't it? – BenMorel Apr 01 '13 at 16:46
  • Last time I set up an EB environment it took about five minutes. Amazon Linux AMIs come out once every three months IIRC. 1.6 minutes a month doesn't strike me as too much pain. – ceejayoz Apr 01 '13 at 16:49
  • Let me rephrase: it *feels* like there must be a better way. But you're right, it's not a big deal. – BenMorel Apr 02 '13 at 08:36
  • 2
    They really ought to post these in some release notes or a sticky in their forums rather than just rolling them out silently. – Ken Liu Dec 08 '13 at 05:46

6 Answers6

2

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).

aws ec2 describe-instances --instance-ids i-0909613f35ec0ffee --query 'Reservations[*].Instances[*].ImageId' --output text

ami-35290a56

Take the resulting AMI ID and describe it.

aws ec2 describe-images --image-ids ami-35290a56 --query 'Images[*][Architecture, Hypervisor, Name, RootDeviceType, VirtualizationType]' --output json

[
    [
        "x86_64",
        "xen",
        "aws-elasticbeanstalk-amzn-2016.03.0.x86_64-python34-hvm-201603290718",
        "ebs",
        "hvm"
    ]
]

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:

aws ec2 describe-images --filters 'Name=architecture,Values=x86_64' 'Name=virtualization-type,Values=hvm' 'Name=owner-alias,Values=amazon' 'Name=name,Values=aws-elasticbeanstalk-amzn-*.x86_64-python34-hvm-*' --query 'sort_by(Images[*], &Name)[-1].ImageId' --output text

ami-1be5de78

Due to the power of lexical sorting and ISO 8601, we end up with the latest AMI, which in my example is ami-1be5de78.

aws ec2 describe-images --image-ids ami-1be5de78 --query 'Images[*].Name' --output text

aws-elasticbeanstalk-amzn-2016.09.0.x86_64-python34-hvm-201612200708

Again, I wouldn't recommend you try to change to this AMI by hand, Beanstalk has provisions to do all this for you!

Nathan
  • 515
  • 2
  • 9
0

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.

0

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.

Iain Watt
  • 21
  • 1
  • 4
0

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.

Martin Ro
  • 1
  • 2
0

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.

ankuj
  • 1
  • 2
-2

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.

user2040074
  • 130
  • 2
  • 1
    I think you misunderstood the question. I didn't ask how to create and use a custom AMI, I asked how to know what is the latest default Elastic Beanstalk AMI id that is applied when you create a new environment, and if possible, how to automatically have the new AMI applied when it's released by AWS. – BenMorel Mar 28 '14 at 20:36