loading...
Cover image for Upgrade AWS Elastic Beanstalk PHP Major version

Upgrade AWS Elastic Beanstalk PHP Major version

paulmicheli profile image Paul Micheli ・3 min read

The AWS Elastic Beanstalk Console currently allows you to change between minor platform versions ( e.g. 64bit Amazon Linux 2018.03 v2.9.10 running PHP 7.1 to64bit Amazon Linux 2018.03 v3.1.10 running PHP 7.1), but doesn’t support changes between major versions (e.g. 64bit Amazon Linux 2018.03 v2.9.10 running PHP 7.1 to 64bit Amazon Linux 2 v3.1.1 running PHP 7.3).

But is it possible to update to a major platform version using the AWS Command Line Interface (CLI):

You will need to get the EnviromentID of the beanstalk environment using the below command;

paulmicheli@minime:~$ aws elasticbeanstalk describe-environments --environment-names APP1

You will get the EnvironmentID from the out;

{
    "Environments": [
        {
            "EnvironmentName": "APP1",
            "EnvironmentId": "e-***********4",
            "ApplicationName": "Application 1",
            "VersionLabel": "app_1_branch-28-09-2020",
            "SolutionStackName": "64bit Amazon Linux 2018.03 v2.9.10 running PHP 7.1",
            "PlatformArn": "arn:aws:elasticbeanstalk:us-east-1::platform/PHP 7.1 running on 64bit Amazon Linux/2.9.10",
            "Description": "PHP 7.1 env",
            "EndpointURL": "app1.elb.amazonaws.com",
            "CNAME": "app1.elb.amazonaws.com",
            "DateCreated": "2019-05-15T10:44:17.800000+00:00",
            "DateUpdated": "2020-09-25T13:01:05.997000+00:00",
            "Status": "Ready",
            "AbortableOperationInProgress": false,
            "Health": "Green",
            "HealthStatus": "Ok",
            "Tier": {
                "Name": "WebServer",
                "Type": "Standard",
                "Version": "1.0"
            },
            "EnvironmentLinks": [],
            "EnvironmentArn": "arn:aws:elasticbeanstalk:us-east-1:123456789101:environment/Application 1/APP1"
        }
    ]
}

You will need to provide the --solution-stack-name these can be found by running this command;

paulmicheli@minime:~$ aws elasticbeanstalk list-available-solution-stacks

Once you have the Environment ID you can run the below command,

paulmicheli@minime:~$ aws elasticbeanstalk update-environment --solution-stack-name "64bit Amazon Linux 2 v3.1.1 running PHP 7.3" --environment-id "e-***********4"

The out put of the command will state the old PlatformArn, this will update once the Environment has updated;

{
    "EnvironmentName": "APP1",
    "EnvironmentId": "e-***********4",
    "ApplicationName": "Application 1",
    "VersionLabel": "app_1_branch-28-09-2020",
    "SolutionStackName": "64bit Amazon Linux 2018.03 v2.9.10 running PHP 7.1",
    "PlatformArn": "arn:aws:elasticbeanstalk:us-east-1::platform/PHP 7.1 running on 64bit Amazon Linux/2.9.10",
    "Description": "PHP 7.1 env",
    "EndpointURL": "app1.elb.amazonaws.com",
    "CNAME": "app1.elb.amazonaws.com",
    "DateCreated": "2019-05-15T10:44:17.800000+00:00",
    "DateUpdated": "2020-09-25T13:29:34.420000+00:00",
    "Status": "Updating",
    "AbortableOperationInProgress": true,
    "Health": "Grey",
    "Tier": {
        "Name": "WebServer",
        "Type": "Standard",
        "Version": "1.0"
    },
    "EnvironmentArn": "arn:aws:elasticbeanstalk:us-east-1:123456789101:environment/Application 1/APP1"
}

Rerun the below command and the PlatformARN will update once the update has completed;

paulmicheli@minime:~$ aws elasticbeanstalk describe-environments --environment-names APP1
{
    "Environments": [
        {
            "EnvironmentName": "APP1",
            "EnvironmentId": "e-***********4",
            "ApplicationName": "Application 1",
            "VersionLabel": "app_1_branch-28-09-2020",
            "SolutionStackName": "64bit Amazon Linux 2 v3.1.1 running PHP 7.3",
            "PlatformArn": "arn:aws:elasticbeanstalk:us-east-1::platform/PHP 7.3 running on 64bit Amazon Linux 2/3.1.1",
            "Description": "PHP 7.1 env",
            "EndpointURL": "app1.elb.amazonaws.com",
            "CNAME": "app1.elb.amazonaws.com",
            "DateCreated": "2019-05-15T10:44:17.800000+00:00",
            "DateUpdated": "2020-09-25T13:30:58.881000+00:00",
            "Status": "Ready",
            "AbortableOperationInProgress": false,
            "Health": "Green",
            "HealthStatus": "Ok",
            "Tier": {
                "Name": "WebServer",
                "Type": "Standard",
                "Version": "1.0"
            },
            "EnvironmentLinks": [],
            "EnvironmentArn": "arn:aws:elasticbeanstalk:us-east-1:123456789101:environment/Application 1/APP1"
        }
    ]
}

Discussion

pic
Editor guide