30

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?

Dan
  • 1,955
  • 17
  • 21
  • For what it's worth, I tried to get a *new* environment up with Puma a couple months ago, and found the thing utterly broken. When I went back to Passenger it just worked. – Gabe Kopley Jun 29 '15 at 18:35
  • Not sure why the heck this question has started at -1 votes...lame sauce. – Dan Jul 03 '15 at 21:39

3 Answers3

59

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
Ralph von der Heyden
  • 1,715
  • 1
  • 15
  • 15
  • That's awesome. Thanks for sharing. I haven't even bothered installing the `awscli`, but I will try that technique out during my next _major_ Ruby version upgrade. – Dan Apr 14 '16 at 20:11
  • 2
    Hi @Gavin, sorry it's not working for you. Maybe it's interesting to see the error message or other output to debug this? – Ralph von der Heyden May 22 '16 at 18:26
  • 2
    Hi @Ralph, this solution will fail if ruby version is specified in gem file. The application fails to start because the ruby version is not matching thus reverting the change. – Gavin May 28 '16 at 11:20
  • 1
    Successfully updated from ruby 2.2 to 2.3 using this method. – Yeonho Nov 11 '16 at 02:42
  • 3
    Had the same problem as @Gavin, solved it by first removing the Ruby version from the Gemfile - now the server will know the Ruby version from the environment instead - then deploying with that Gemfile; then running the command ( `aws elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2016.09 v2.3.2 running Ruby 2.3 (Puma)" --environment-name "env"` ). After that feel free to re-add the Ruby version to the Gemfile, but notice that it must match the one on their server, e.g. the current latest is 2.3.3, but the server has only 2.3.1. – Velizar Hristov Mar 29 '17 at 15:08
  • Thanks for sharing! I have a doubt about the RDS. I have the elastic beanstalk environment attached to a RDS, do I have to create a new RDS or the `update-enviroment` command does nothing with the RDS? – MatayoshiMariano Jun 09 '17 at 14:30
  • 1
    @MatayoshiMariano RDS won't be touched by this. – Ralph von der Heyden Jun 12 '17 at 08:14
  • @RalphvonderHeyden awsome! I have used this command and I have upgraded from ruby 2.1 to 2.3 succesfully! Thanks! – MatayoshiMariano Jun 12 '17 at 12:47
  • 7
    For people looking for all available solution-stack-name you could run following command `aws elasticbeanstalk list-available-solution-stacks` – Lewy Aug 23 '17 at 22:32
  • Also mention `version-label` to upgrade along with the corresponding Gemfile/code changes (see https://stackoverflow.com/a/35207353/184184) – Raj Sep 02 '17 at 06:26
  • This is great, and it's a pity that it's not well documented in AWS docs. Here's an example for Ruby 2.3 => 2.4 upgrade in Ohio `aws elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2017.09 v2.6.1 running Ruby 2.4 (Puma)" --environment-name "my-environment-blabla" --region "us-east-2"` – januszm Nov 17 '17 at 10:52
2

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.

Dan
  • 1,955
  • 17
  • 21
0

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.