我有一个不会更新的 Elastic Beanstalk 应用程序。在 TechOps 建议我将 CloudFormation 模板中的
SolutionStackName
从 64bit Windows Server 2019 v2.7.0 running IIS 10.0
更新为 64bit Windows Server 2019 v2.13.1 running IIS 10.0
后,部署开始失败。 “部署”后,堆栈最终会处于 grey
状态,但部署永远不会发生。登录 EC2 实例不会查看 C:\Program Files\Amazon
文件夹中的任何日志,脚本也不会创建 C:\cfn
。堆栈将失败并返回 The EC2 instances failed to communicate with AWS Elastic Beanstalk, either because of configuration problems with the VPC or a failed EC2 instance. Check your VPC configuration and try launching the environment again.
解决此问题的方法是在更新 CloudFormation 模板中的
SolutionStackName
后,您还必须更新 AMI ImageId
字段,否则您所要求的内容与您提供的图像之间会不同步。至于为什么AWS不验证这一点,我不知道。我发现获取此 ID 的最简单方法是在 Web 控制台中创建一个新堆栈,在实际创建它之前,它会向您显示要使用的正确 ID。我过去没有成功地使用 CLI 来获取 AMI。
最后你需要有这样的东西:
EBConfig:
Type: "AWS::ElasticBeanstalk::ConfigurationTemplate"
Condition: CreateServerResources
Properties:
ApplicationName: !Ref EBApplication
# If you change this you need to change the ImageId below as well or the stack will not work
SolutionStackName: 64bit Windows Server 2019 v2.13.1 running IIS 10.0
OptionSettings:
# AMI -- Change me when updating the SolutionStackName
- Namespace: aws:autoscaling:launchconfiguration
OptionName: ImageId
Value: ami-0b72372231dfb015c
弄清楚这一点比我愿意承认的要花更长的时间,我希望这对将来遇到类似问题的人有所帮助。