How does ruby version get set and updated on ELB?
I've been using ruby 2.2.2
on our qa and staging env's for about 8 months now. I just setup our production env Monday and it wouldn't deploy as it said ruby was set to 2.2.3 and my gemfile said 2.2.2. I updated and redeployed and everything seemed to be fine.
I came back to the qa/staging env's and can't get it to update to ruby 2.2.3. Kept saying ruby version is 2.2.2 and Gemfile is 2.2.3
I upgraded (through elb ui):
64bit Amazon Linux 2015.03 v1.3.1 running Ruby 2.2 (Passenger Standalone)
to
64bit Amazon Linux 2015.09 v2.0.6 running Ruby 2.2 (Passenger Standalone)
Now it says Your Ruby version is 2.2.3, but your Gemfile specified 2.2.2
. There has to be an easier way to do this.
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.
I found a different approach to this problem.
The way I made it work is similar to the comment above with a small change.
Steps I did:
- 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) - used the sample application for faster and easier launch.
- 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
- Created a custom AMI from the instance running ruby 2.3 with everything installed
- Used the same command that Rohit 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 @Rohit Banga suggested command failed on every try.
Not to forget, I have also specified the ruby version "2.3.7" in my Gemfile as well.