I am receiving the following error when trying to use a CloudFormation template to create a stack:
Resource handler returned message: "Resource of type ‘AWS::ElasticBeanstalk::Environment’ with identifier ‘[AppName]-Env-lee-test’ did not stabilize." (RequestToken: [Request GUID], HandlerErrorCode: NotStabilized)
The project is an ASP.NET Core web site and the template contains the following resources:
- An Elastic Beanstalk application.
- A version of the application using a source bundle in S3.
- An Elastic Beanstalk environment.
CloudFormation Template:
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
BuildNumber:
Description: The build number which specified the build of software we want to deploy. This should exist as a folder in the artifacts bucket.
Type: String
Resources:
DashboardApplication:
Type: AWS::ElasticBeanstalk::Application
Properties:
ApplicationName: !Join [ "-", [ "AppName", !Ref AWS::StackName ] ]
Description: App Name Web Dashboard
DashboardAppVersion:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
ApplicationName: !Ref DashboardApplication
Description: !Join [ " ", [ "App Name Web Dashboard ", !Ref BuildNumber ] ]
SourceBundle:
S3Bucket: artifacts
S3Key: !Join [ "/", [ !Ref BuildNumber, Dashboard.zip ] ]
DashboardEnvironment:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName: !Ref DashboardApplication
EnvironmentName: !Join [ "-", [ "AppName-Env", !Ref AWS::StackName ] ]
SolutionStackName: 64bit Amazon Linux 2 v2.5.0 running .NET Core
Tags:
- Key: Name
Value: !Join [ "-", [ "AppName-Env", !Ref AWS::StackName ] ]
Tier:
Name: WebServer
Type: Standard
VersionLabel: !Ref DashboardAppVersion
I have found this troubleshooting link which suggests running the stack creation as a service role. I am doing this and the error remains. The only other suggestion is to contact AWS Support and we do not have technical support on our price plan.
I have created an Elastic Beanstalk application and environment using the same source bundle through the AWS console, and that succeeds.
I’m not sure where to go for more information about what is going wrong here. Have I made a mistake or missed something in my template?
2
Answers
The cause of this error was the absence of an "IamInstanceProfile" option setting on the Environment resource. This YAML solved it:
Although the error shown on the stack creation page did not include helpful information, if you open the failed environment (which should be there in a terminated state) in the console, you can get a more detailed error by looking at the Events.
Usually whenever I’ve ran into "Resource didn’t stabilize" it has something to do with the health check in either the scaling group or the load balancer. I think the default is for it to check
/
every so often for a 200 response. Make sure your app can either satisfy that call or that you customize the health check for your application to some kind of "pulse" endpoint.