AWS Elastic Beanstalk - How To Upgrade Existing En

2019-01-22 02:52发布

AWS Elastic Beanstalk - Cannot Clone With Latest Platform or eb upgrade from Ruby 2.1 to Ruby 2.2

I've been smashing my head on this one. Back in May, AWS announced that their Ruby Elastic Environments now offer Ruby-2.2 (e.g. ruby-2.2-(passenger-standalone) or ruby-2.2-(puma)). I can't upgrade my existing ruby-2.1 environments to ruby-2.2. It appears I have to recreate them completely...that seems silly? Anyone else out there experiencing this? Am I just missing something simple?

Extra Information

I've been gleefully using ruby-2.1-(passenger-standalone) for several months in my staging and production environments. Now I'd like to upgrade them to the latest ruby-2.2 platform. The AWS documentation says this is pretty trivial, in fact some of their documentation even appear to state that you can use an eb clone <env-name> --update. That flag doesn't exist in the EB CLI 3.4.5 that I'm using :( Additionally, the web console has a Clone with Latest Platform option menu item, yet it is disabled.

It appears that all I can do to get to the latest Ruby-2.2 instances is to create a brand new environment from scratch. That's tremendously annoying.

So here's what I've tried...

$ eb status
Environment details for: staging
  Application name: xyz
  Region: us-west-2
  Deployed Version: fbe7
  Environment ID: someId
  Platform: 64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.1 (Passenger Standalone)
  Tier: WebServer-Standard
  CNAME: bla.bla.bla.elasticbeanstalk.com
  Updated: 2015-06-26 22:48:59.689000+00:00
  Status: Ready
  Health: Green

Great, confirms I'm using Ruby 2.1. So let's try to upgrade:

$ eb upgrade
Environment already on most recent platform version.

Okay, that's nice, so what about the platform itself:

$ eb platform select
It appears you are using Ruby. Is this correct?
(y/n): y

Select a platform version.
1) Ruby 2.2 (Puma)
2) Ruby 2.2 (Passenger Standalone)
3) Ruby 2.1 (Puma)
4) Ruby 2.1 (Passenger Standalone)
5) Ruby 2.0 (Puma)
6) Ruby 2.0 (Passenger Standalone)
7) Ruby 1.9.3
(default is 1): 2

So now, here's my platform settings:

$ eb platform show
Current default platform: Ruby 2.2 (Passenger Standalone)
New environments will be running:  64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.2 (Passenger Standalone)

Platform info for environment "staging":
Current: 64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.1 (Passenger Standalone)
Latest:  64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.1 (Passenger Standalone)

So New environments will take advantage of the Ruby-2.2 editions. That's great, but do I seriously have to retire my already configured Ruby-2.1 editions in lieu of a newly created Ruby-2.1 edition? Come on?

3条回答
甜甜的少女心
2楼-- · 2019-01-22 03:24

I found a different approach to this problem.

The way I made it work is similar to the comment above but I managed to update the existing beanstalk environment and not deploy code to a completely new one.

Steps I did:

  1. Launched a completely new environment on beanstalk running the ruby version that I need, 2.3 (in my case I needed an update from Ruby 2.2 to Ruby 2.3)
  2. SSH-ed into the new instance and installed all dependencies that my application needs (packages, dev tools etc.) - you can also do these in the .ebextensions directory
  3. Created a custom AMI from the instance running ruby 2.3 with everything installed
  4. Used the same command that Ralph posted but with some tweeks:
aws elasticbeanstalk update-environment --region "REGION" --environment-name "ENV_NAME" --solution-stack-name "64bit Amazon Linux 2018.03 v2.8.1 running Ruby 2.3 (Puma)" --option-settings Namespace=aws:autoscaling:launchconfiguration,OptionName=ImageId,Value="ami- 
xxxxxxxx"

The AMI option-settings was key for me, as this helped me the AMI with ruby 2.3.7 installed to be used for launching the new instance on the existing environment. Previously just hitting Ralph's suggested command failed on every try.

查看更多
冷血范
3楼-- · 2019-01-22 03:26

My solution to this challenge was to:

  1. Launch a brand new environment.
  2. Create a Web Application or Worker.
  3. Choose the environment you want, likely the latest greatest. In my case Passenger with Ruby-2.2.
  4. I choose to deploy the Sample Application so that the new environment succeeds.
  5. Choose the remaining options for your new environment and let it launch.

Upon successful launch, I set up all my environment variable; e.g. all my database, smtp, RAILS_ENV/RACK_ENV, etc. Then I go to my previously deployed applications, and simply deploy my latest quality version to the brand new environment.

One would agree that this is a lot more work than a simple eb upgrade. Lame sauce.

查看更多
迷人小祖宗
4楼-- · 2019-01-22 03:27

I found a solution for this, by using the aws cli (NOT the eb cli):

aws elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2016.03 v2.1.0 running Ruby 2.3 (Puma)" --environment-name "dev-bg-123456" --region "us-east-1"

The aws cli can be installed with homebrew:

brew install awscli
查看更多
登录 后发表回答