gpt4 book ai didi

amazon-web-services - 使用 CloudFormation 部署 Elastic Beanstalk 环境

转载 作者:行者123 更新时间:2023-12-03 07:41:46 24 4
gpt4 key购买 nike

我有以下 CF 模板来部署 EB 环境:

Resources:

EBEC2Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
Service:
- 'ec2.amazonaws.com'
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier'
- 'arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier'
- 'arn:aws:iam::aws:policy/AWSElasticBeanstalkMulticontainerDocker'
RoleName: 'aws-elasticbeanstalk-ec2-role'


EBServiceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
Service:
- 'elasticbeanstalk.amazonaws.com'
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkEnhancedHealth'
- 'arn:aws:iam::aws:policy/service-role/AWSElasticBeanstalkService'
RoleName: 'aws-elasticbeanstalk-service-role'

EBApplication:
Type: AWS::ElasticBeanstalk::Application
Properties:
ApplicationName: 'Freyja'
Description: 'Freyja EB Application'

EBAppVersion:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
ApplicationName:
Ref: EBApplication
Description: 'App version'
SourceBundle:
S3Bucket:
Fn::ImportValue:
Fn::Sub: 'S3MainBucket'
S3Key: 'python.zip'

EBEnv:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName:
Ref: EBApplication
Description: 'Freyja main environment'
EnvironmentName: 'Freyja'
SolutionStackName: '64bit Amazon Linux 2 v3.1.4 running Python 3.7'
OptionSettings:
- Namespace: 'aws:autoscaling:launchconfiguration'
OptionName: 'InstanceType'
Value: 't2.nano'
- Namespace: 'aws:autoscaling:launchconfiguration'
OptionName: 'IamInstanceProfile'
Value: !Ref EBEC2Role
- Namespace: 'aws:elasticbeanstalk:environment'
OptionName: 'ServiceRole'
Value: !Ref EBServiceRole
VersionLabel:
Ref: EBAppVersion

但是,我在 CF 中创建它时不断收到错误:

Environment failed to launch as it entered Terminated state

我查了很多文档,似乎找不到原因。请记住,我们的想法是将其部署在一个全新的帐户中,这就是我在模板中创建角色的原因,除了用于创建 S3 存储桶的单独 CF 模板之外,其中没有任何内容。

最佳答案

这可能是因为 IamInstanceProfile 应该是实例配置文件,而不是角色。所以你可以按如下方式添加:

  EBInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref EBEC2Role

然后:

        - Namespace: 'aws:autoscaling:launchconfiguration'
OptionName: 'IamInstanceProfile'
Value: !Ref EBInstanceProfile

关于amazon-web-services - 使用 CloudFormation 部署 Elastic Beanstalk 环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65863754/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com