Jan Horčička
Jan Horčička

Reputation: 853

Create Amazon Linux 2 instance via CodeStar

I have created a Java Web application with Elastic Beanstalk using AWS CodeStar. The application works, no problem there. But the EC2 instance the Elastic Beanstalk provisioned is running Amazon Linux 1. I need to have Amazon Linux 2, because some of the things I want to install there run only on Amazon Linux 2. The AMI used for the instance is aws-elasticbeanstalk-amzn-2018.03.0.x86_64-tomcat8.5java8-hvm-202102251130.

When you are creating a project via CodeStar, you can only select instance type (I selected t3.micro for start). There is no way to select operating system. You also cannot specify OS in the EC2 console or Elastic Beanstalk console. Solution might be to select a different AMI in the Auto-scaling group, but I am not sure if the template provided by CodeStar will work on AL2, since it was built for AL1.

So my question is:

  1. Is there an easy way to get a AL2 instance for a CodeStar project?
  2. If the only solution is to specify AMI, which one should it be and how to make sure my project will work there?

Upvotes: 1

Views: 199

Answers (1)

Marcin
Marcin

Reputation: 238727

There are two ways to change it, but I don't know if forcing EB platform version change won't break some CodeStar compatibilities. Anyway, you can give it a go, if you want.

First option, you can go to your source code repo, and open template.yml. Find line SolutionStackName: !Ref 'SolutionStackName' and change to which platform you want, e.g.:

      SolutionStackName: 64bit Amazon Linux 2 v4.1.6 running Tomcat 8.5 Corretto 11   

The change should trigger re-deployment of your CodeStar project and EB env.

Or second option, go to CodePiepline of your CodeStar project and edit Deploy stage's GenerateChangeSet action. In the Advanced settings of the action, got to Parameter overrides and "SolutionStackName":"64bit Amazon Linux 2018.03 v3.4.4 running Tomcat 8.5 Java 8", to what you want, e.g.:

  "SolutionStackName":"64bit Amazon Linux 2 v4.1.6 running Tomcat 8.5 Corretto 11",

Please not that you may need also to add permissions to the role CodePipeline uses for CloudFormation. The name of the role can be found in GenerateChangeSet action details. Once you have the name, you can go to IAM console, and add missing permissions. In my test, I did try to find minimum needed permissions, so I just added bunch of them (bad practice):

AmazonEC2FullAccess
AdministratorAccess-AWSElasticBeanstalk
AWSCloudFormationFullAccess

Finally, the demo application that CodeStar uses probably will not work with the updated environment as it was designed for older EB platforms, not new ones.

Upvotes: 1

Related Questions