The AWS web interface for ElasticBeanstalk doesn’t let you update Ruby. Thankfully there is a way to do it via the command line using the aws utility.

First, we need to identify the so-called “solution stack name” we want to use:

$ aws --profile foo elasticbeanstalk list-available-solution-stacks | grep -E "SolutionStackName.+ Ruby 2\.5"
            "SolutionStackName": "64bit Amazon Linux 2017.09 v2.7.1 running Ruby 2.5 (Puma)",
            "SolutionStackName": "64bit Amazon Linux 2017.09 v2.7.1 running Ruby 2.5 (Passenger Standalone)",

Then we need to retrieve the environment name:

aws --profile foo elasticbeanstalk describe-environments | grep "EnvironmentName"
            "EnvironmentName": "foobar-rails",

Finally, we can update the environment:

aws --profile foo elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2017.09 v2.7.1 running Ruby 2.5 (Puma)" --environment-name foobar-rails

Done!

It will take a few minutes to redeploy your app. I like to monitor it using eb health --refresh.