通过 CodeStar 创建 Amazon Linux 2 实例 [英] Create Amazon Linux 2 instance via CodeStar

查看:20
本文介绍了通过 CodeStar 创建 Amazon Linux 2 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 AWS CodeStar 通过 Elastic Beanstalk 创建了一个 Java Web 应用程序.该应用程序有效,没有问题.但是 Elastic Beanstalk 配置的 EC2 实例正在运行 Amazon Linux 1.我需要有 Amazon Linux 2,因为我想在那里安装的一些东西只能在 Amazon Linux 2 上运行.用于实例的 AMI 是 aws-elasticbeanstalk-amzn-2018.03.0.x86_64-tomcat8.5java8-hvm-202102251130.

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.

当您通过 CodeStar 创建项目时,您只能选择实例类型(我选择 t3.micro 作为开始).没有办法选择操作系统.您也不能在 EC2 控制台或 Elastic Beanstalk 控制台中指定操作系统.解决方案可能是在 Auto-scaling 组中选择不同的 AMI,但我不确定 CodeStar 提供的模板是否适用于 AL2,因为它是为 AL1 构建的.

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.

所以我的问题是:

  1. 是否有一种简单的方法可以为 CodeStar 项目获取 AL2 实例?
  2. 如果唯一的解决方案是指定 AMI,那么应该是哪一个,以及如何确保我的项目能够在那里运行?

推荐答案

两种方法可以改,但不知道强制改EB平台版本会不会破坏一些CodeStar 兼容性.不管怎样,如果你愿意,你可以试一试.

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.

第一个选项,您可以转到您的源代码存储库,然后打开 template.yml.找到行 SolutionStackName: !Ref 'SolutionStackName' 并更改为您想要的平台,例如:

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   

更改应该会触发您的 CodeStar 项目和 EB 环境的重新部署.

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

第二个选项,转到CodeStar 项目的CodePiepline 并编辑Deploy 阶段的GenerateChangeSet 动作.在操作的 Advanced 设置中,转到 Parameter overridesSolutionStackName":64bit Amazon Linux 2018.03 v3.4.4 running Tomcat 8.5 Java 8", 到你想要的,例如:

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",

请注意,您可能还需要向 CodePipeline 用于 CloudFormation 的角色添加权限.角色名称可以在 GenerateChangeSet 操作详细信息中找到.获得名称后,您可以转到 IAM 控制台,并添加缺少的权限.在我的测试中,我确实尝试找到所需的最低权限,所以我只是添加了一堆(不良做法):

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

最后,CodeStar 使用的演示应用程序可能不适用于更新后的环境,因为它是为旧的 EB 平台而非新平台设计的.

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.

这篇关于通过 CodeStar 创建 Amazon Linux 2 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆