Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve "Resource did not stabilize" when creating stack in AWS CloudFormation?

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?

like image 334
Lee D Avatar asked Oct 19 '25 23:10

Lee D


1 Answers

The cause of this error was the absence of an "IamInstanceProfile" option setting on the Environment resource. This YAML solved it:

OptionSettings:
- Namespace: aws:autoscaling:launchconfiguration
  OptionName: IamInstanceProfile
  Value: aws-elasticbeanstalk-ec2-role

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.

like image 118
Lee D Avatar answered Oct 22 '25 15:10

Lee D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!