Aws Elastic Beanstalk - How to Upgrade Existing Environment from Ruby 2.1 to Ruby 2.2

AWS Elastic Beanstalk - How To Upgrade Existing Environment from Ruby 2.1 to Ruby 2.2

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

Upgrade Ruby on Elastic Beanstalk

Since you want to update both the platform and the version label at the same time you can always use the UpdateEnvironment API specifying both the solution stack name and version label parameters.

http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_UpdateEnvironment.html

You can use the aws cli or sdk to do this.

Step-By-Step as described by @Scott:

  • Update Gemfile to match ruby version on new platform
  • Zip up codebase (including .elasticbeanstalk and .ebextensions),
  • Upload to elb through application versions (AWS Console -> EB -> All applications -> Application Versions)
  • Run aws elasticbeanstalk update-environment --environment-name "corresponding_env_name" --solution-stack-name "64bit Amazon Linux 2015.09 v2.0.6 running Ruby 2.2 (Passenger Standalone)" --version-label "zip_name_you_uploaded"
  • Everything deployed correctly
  • Drink some beer.

Change platform on Elastic Beanstalk from PHP to Node.js

I think you can use this solution:

aws elasticbeanstalk list-available-solution-stacks

aws elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2017.09 v4.4.4 running Node.js" --environment-name "example-env" --region "eu-west-1"

issue deploying rails 5 application to AWS using Elastic Beanstalk due to rb-readline

I had a similar error, but with dot-env rails gem. It looks like it might be same root cause.

It appeared to be because $HOME was not set by AWS during the deploy, and a call to File.expand_path dies when it's not set.

Possible fixes:

  1. Remove rbreadline
  2. Add a HOME environment variable into your EB configuration or eb setenv (and redeploy)
  3. Add a config file that overwrites the existing deploy script & adds a $HOME variable before the bundle install command is run

I successfully tried the first and last option, and settled with using a forked version of the Gem that handled a missing $HOME correctly.

I suspect the 2nd version is the more correct way to do it, but to be honest it's unclear why Amazon didn't set a $HOME to begin with, and what it should actually be.

The app will exist in either /var/app/ondeck or /var/app/current so either one of those two folders, or /home/webapp (per the error) all might be a good value to start with.

This may not be 100% the root cause because I've had varying degrees of luck with replicating this locally with different versions of Ruby. However, the expand_path docs do say HOME must be set correctly so this may be the cause.

https://ruby-doc.org/core-2.4.2/File.html#method-c-expand_path

More detail on working solutions:

I found two solutions that worked (try one or the other)

At one point I did submit a PR with dotenv to fix this issue. https://github.com/bkeepers/dotenv/pull/314. As far as I recall, this fixes it, and doesn't break anything else. The issue was marked as wontfix by the automated bot, but has recently been re-opened by the new maintainers

I ultimately switched back to the ebextensions approach after it was clear my PR wouldn't be merged, but last I recall it was functioning as expected (and I think the better approach)

The other solution I used was to create a new config file that replaced the /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh file.

  • Get the current version of that file from an existing application server
  • Create an ebextension config that creates that file (it will overwrite the original) but include a line to set the $HOME variable before the bundle install command is run.
  • Set the $HOME value to whatever it would be for the default user

The documentation for creating such a file using ebextensions are here:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-files



Related Topics



Leave a reply



Submit