- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的 Cloudformation 堆栈中创建一个 LaunchTemplate,它引用 IamInstanceProfile。这是代码 - 我省略了不相关的部分:
...
Resources:
ServerLaunchTemplate:
Type: 'AWS::EC2::LaunchTemplate'
Properties:
LaunchTemplateData:
InstanceType: !Ref InstanceType
SecurityGroups:
- !Ref SecGroup
IamInstanceProfile: !Ref ServerProfile
UserData:
...
ServerProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: /
Roles:
- !Ref ServerRole
...
ServerProfile 已成功创建。但是,当堆栈创建过程到达创建 ServerLaunchTemplate 的步骤时,它会失败并出现错误:
Property validation failure: [Value of property {/LaunchTemplateData/IamInstanceProfile} does not match type {Object}]
如果我省略对 IamInstanceProfile 的引用,LaunchTemplate 将成功创建。
根据documentation以及一些应该可以工作的示例...根据我理解的错误,LaunchTemplate 的 InstanceType 字段需要引用一个对象,但是“!Ref InstanceType”返回资源 ID。
我该如何解决这个问题?我如何检索“/LaunchTemplateData/IamInstanceProfile”字段可能需要的对象?
谢谢
最佳答案
文档中很容易错过:IamInstanceProfile 需要一个 IamInstanceProfile Cloudformation 对象,引用的 IamInstanceProfile 的 Arn 是它的一个属性。
参见https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata.html#cfn-ec2-launchtemplate-launchtemplatedata-iaminstanceprofile和 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-iaminstanceprofile.html .
这应该有效:
PortalLaunchTemplate:
Type: 'AWS::EC2::LaunchTemplate'
Properties:
LaunchTemplateName: !Sub ${InstanceName}-launch-template
LaunchTemplateData:
ImageId: !Ref AmiId
...
IamInstanceProfile:
Arn: !GetAtt InstanceProfile.Arn
关于aws-cloudformation - 引用 IamInstanceProfile 的 Cloudformation LaunchTemplate 无法创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53854184/
我正在尝试在我的 Cloudformation 堆栈中创建一个 LaunchTemplate,它引用 IamInstanceProfile。这是代码 - 我省略了不相关的部分: ...
我正在使用 AWS CDK 创建和更新 LaunchTemplate,例如 new ec2.LaunchTemplate(stack, "my-template", { launchTemplat
我正在创建一个 CloudFormation 模板来部署一个仅应使用竞价实例的自动缩放组。 Cloudformation 使用此模板引发错误。这里出了什么问题? 错误:CREATE_FAILED 遇到
目标:为 ASG 设置 EC2 启动模板,并具有网络接口(interface)设置。 详细信息:ASG 将在公共(public)子网中启动,并尽量避免拥有公共(public) IP。 CFN 摘录示例
在开发 CloudFormation 模板时,我遵循最小权限原则。因此,我为 CloudFormation 提供了一个角色来承担,并且该角色具有最小的权限集。 该模板包含一个 AWS::AutoSca
我正在尝试使用 CloudFormation cfn-init 在基于 Ubuntu 18.04 构建的集群中引导创建按需计算节点。由于某种原因,cnf-init 进入死循环。这是我尝试使用的 Clo
我是一名优秀的程序员,十分优秀!