I have an Elastic Beanstalk application that will not update. After TechOps suggested I update the SolutionStackName
in the CloudFormation template from 64bit Windows Server 2019 v2.7.0 running IIS 10.0
to 64bit Windows Server 2019 v2.13.1 running IIS 10.0
, things started to fail to deploy. The stack would end up in a grey
state after "deploying" but deployment would never occur. Logging into the EC2 instance would not review any logs in the C:\Program Files\Amazon
folder nor was C:\cfn
being created by the scripts. The stack would fail and return 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.
The way to fix this is after updating the SolutionStackName
in the CloudFormation template, you have to also update the AMI ImageId
field as well or there is a desync between what you are asking for and what image you are providing. As to why AWS doesn't validate this, I have no idea. The easiest way I've found to get this ID, is to create a new stack in the web console and before you actually create it, it will show you the correct ID to use. I haven't had any luck using the CLI to obtain the AMI in the past.
In the end you need to have something like this:
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
This took longer to figure out than I wish to admit, and I hope this helps anyone in the future with a similar problem.
Another way to find the AMI ID is to execute this powershell script. As long as you are looking for the latest AMI ID, the script sorts the latest version to the top.
$platform_values = New-Object 'collections.generic.list[string]'
$platform_values.add("windows")
$filter_platform = New-Object Amazon.EC2.Model.Filter -Property @{Name = "platform"; Values = $platform_values}
Get-EC2Image -Owner amazon, self -Filter $filter_platform | Where Name -like "aws-elasticbeanstalk*-WindowsServer2019-V2*" | sort CreationDate -Descending | Select ImageId, Name, CreationDate | Out-GridView