如何解决在创建AWS CloudFormation堆栈时出现的”Resource did not stabilize”错误?

huangapple go评论81阅读模式
英文:

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

问题

我在尝试使用CloudFormation模板创建堆栈时遇到了以下错误:

> 资源处理程序返回的消息:“类型为'AWS::ElasticBeanstalk::Environment'的资源标识为'[AppName]-Env-lee-test'没有稳定下来。”(请求令牌:[请求GUID],处理程序错误代码:未稳定)

该项目是一个ASP.NET Core网站,模板包含以下资源:

  • Elastic Beanstalk应用程序。
  • 使用S3中的源包创建的应用程序版本。
  • Elastic Beanstalk环境。

CloudFormation模板:

AWSTemplateFormatVersion: "2010-09-09"

Parameters:
  BuildNumber:
    Description: 指定要部署的软件版本的构建号。这应该存在于工件存储桶中的文件夹中。
    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: 64位Amazon Linux 2 v2.5.0运行.NET Core
      Tags:
        - Key: Name
          Value: !Join [ "-", [ "AppName-Env", !Ref AWS::StackName ] ]
      Tier: 
        Name: WebServer
        Type: Standard
      VersionLabel: !Ref DashboardAppVersion

我找到了这个故障排除链接,建议以服务角色身份运行堆栈创建。我正在这样做,但错误仍然存在。唯一的建议是联系AWS支持,但我们的价格计划中没有技术支持。

我通过AWS控制台创建了相同源包的Elastic Beanstalk应用程序和环境,并成功完成。

我不确定在这里获取更多关于出错原因的信息。我是否犯了错误或在模板中漏掉了什么?

英文:

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?

答案1

得分: 3

这个错误的原因是在环境资源上没有设置 "IamInstanceProfile" 选项。以下的YAML代码解决了这个问题:

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

虽然堆栈创建页面上显示的错误信息不够详细,但如果你在控制台中打开已终止状态的失败环境,你可以通过查看事件来获取更详细的错误信息。

英文:

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.

答案2

得分: 0

通常每当我遇到"Resource didn't stabilize"时,它通常与伸缩组或负载均衡器中的健康检查有关。我认为默认情况下它会定期检查/以获取200响应。确保您的应用程序可以满足该调用,或者自定义应用程序的健康检查以指向某种 "脉冲" 终点。

英文:

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.

huangapple
  • 本文由 发表于 2023年3月7日 22:37:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663351.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定