Upgrading An Elastic Beanstalk Platform: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
Line 44: Line 44:
* Click '''Edit inbound rules'''
* Click '''Edit inbound rules'''
** Add 3 rules:  
** Add 3 rules:  
** HTTPS, source ::/0
** HTTPS, source ::/0 (Anywhere IPv6)
** SSH,  source [REMOTE_IP]/32
** HTTPS, source 0.0.0.0/0 (Anywhere IPv4)
** HTTPS, source 0.0.0.0/0
** SSH,  source [REMOTE_IP]/32 (My IP)


==== Create a key pair ====
==== Create a key pair ====

Revision as of 14:59, 20 August 2022

Overview

Over time Amazon Web Services will send notices that an Elastic Beanstalk's platform will no longer be supported in the future. Eventually the environment will be tagged as "deprecated" in the EBS console.

There is an option within the EBS console under Environment > Platform to "Change" the platform. This leads to a dialog with a dropdown menu of the available platform options. I have run into situations where the available options are all older than the current platform and so are all deprecated.

In these cases it is necessary to create a new EBS application and new EBS environments within that application. These environments will have the latest platforms. It may be true that some upgrades may require a new application, but see if the desired platform is available in a new EBS environment first. It is usually necessary to update the configuration of those environments to suit the different layout of the updated platform.

Create new EBS environment

Select tier

Select environment tier: Web server environment

Create a web server environment

Application name: Will create a new application for the environment. Try entering an existing application name?

Environment name: [Environment identifier]

Platform: Managed platform

Platform: Choose the platform for the environment, e.g. PHP, Python, etc. Platform branch: Version of the environment.

Application code: Sample application (this will be overwritten with eb deploy

Wait for the environment to be created. The status under Health will change from "pending" to "ok".

A new EC2 instance will be created for the new EBS environment.

Copy configuration

Copy any configuration stored in the old environment.

Environment > Configuration > Software > Edit > Environment Properties

Configure EC2 instance

Add inbound rules

  • EC2 console > Security Groups > Select EC2 instance from list
  • In the instance details below, click the Inbound rules tab.
  • Click Edit inbound rules
    • Add 3 rules:
    • HTTPS, source ::/0 (Anywhere IPv6)
    • HTTPS, source 0.0.0.0/0 (Anywhere IPv4)
    • SSH, source [REMOTE_IP]/32 (My IP)

Create a key pair

See Key Pairs in Enabling SSH Connections to an Elastic Beanstalk Environment

Update DNS

  • Route 53 console > Hosted zones > Select domain name > View Details button
  • Select a hosted subdomain > Edit record button > Select the new EBS environment under Route traffic to

Deploy app

Update ESB environment app settings

In the local project, update environment settings in .elasticbeanstalk/config.yml:

  • branch-defaults.develop.environment
  • branch-defaults.master.environment
  • environment-defaults
  • global.application_name
  • global.default_ec2_keyname
  • global.default_platform

Confirm GitHub access, if needed

If the deployment requires installing anything from private GitHub repos, confirm that the GitHub personal access token has not expired.

Deploy the app using eb-cli

Deploy the app with

$ eb deploy

Or with the --staged option if files have been modified but not pushed to remote yet. The files have to be added to the commit to be included.

$ eb deploy --staged

Cleanup

Delete the old EBS environment and its EC2 instance as soon as possible to avoid unnecessary charges.