Environment failed to launch as it entered Terminated state

谁说我不能喝 提交于 2020-05-29 11:01:05

问题


Setup
Serverless.com Framework

Goal
Create AWS Elastic Beanstalk trough serverless

Code
serverless.yml

service: aws-beanstalk-sls
description: Test stack deployment 😀

provider:
  name: aws
  stage: running
  region: eu-central-1
  profile: beanstalk-test-deployment

resources:
  Resources:
    sampleApplication:
      Type: AWS::ElasticBeanstalk::Application
      Properties:
        Description: AWS Elastic Beanstalk Sample Application

    sampleApplicationVersion:
      Type: AWS::ElasticBeanstalk::ApplicationVersion
      Properties:
        ApplicationName:
          Ref: sampleApplication
        Description: AWS ElasticBeanstalk Sample Application Version
        SourceBundle:
          S3Bucket: elasticbeanstalk-samples-eu-central-1
          S3Key: nodejs-sample.zip

    sampleConfigurationTemplate:
      Type: AWS::ElasticBeanstalk::ConfigurationTemplate
      Properties:
        SolutionStackName: 64bit Amazon Linux 2018.03 v4.7.0 running Node.js
        Description: AWS ElasticBeanstalk Sample Configuration Template
        ApplicationName:
          Ref: sampleApplication
        OptionSettings:
        - Namespace: aws:autoscaling:asg
          OptionName: MinSize
          Value: '2'
        - Namespace: aws:autoscaling:asg
          OptionName: MaxSize
          Value: '6'
        - Namespace: aws:elasticbeanstalk:environment
          OptionName: EnvironmentType
          Value: LoadBalanced

    sampleEnvironment:
      Type: AWS::ElasticBeanstalk::Environment
      Properties:
        ApplicationName:
          Ref: sampleApplication
        Description: AWS ElasticBeanstalk Sample Environment
        TemplateName:
          Ref: sampleConfigurationTemplate
        VersionLabel:
          Ref: sampleApplicationVersion

Error
An error occurred: sampleEnvironment - Environment failed to launch as it entered Terminated state.

Note
The profile beanstalk-test-deployment has already the IAM roles:

  • AWSElasticBeanstalkFullAccess
  • AdministratorAccess

回答1:


You need to create the aws-elasticbeanstalk-ec2-role AWS::IAM::InstanceProfile and provide it in the sampleConfigurationTemplate's OptionSettings:

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

The role can use these Managed Policy Arns:

- arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier
- arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier
- arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker

If adding this role doesn't help, the error could also indicate a failing .ebextensions. I once got this error by calling a nonexistent KeyName in ebextensions.



来源:https://stackoverflow.com/questions/53392302/environment-failed-to-launch-as-it-entered-terminated-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!