amazon-web-services - CloudFormation !Ref 未按预期工作
问题描述
我有下面的模板,它描述了一个新的 OpsWorks 堆栈。它依赖于帐户中已经存在的两个角色,但我需要使用 !Ref 作为帐户 ID,因为此模板可以在任何地方生成堆栈。
Stack4:
Type: AWS::OpsWorks::Stack
Condition: CreateStack4
Properties:
Name: !Ref StackName4
DefaultOs: 'Amazon Linux 2'
VpcId: !Ref VpcId
DefaultSubnetId: !Ref SubnetId
UseOpsworksSecurityGroups: True
CustomCookbooksSource:
Type: 's3'
Url: https://oidigital-chef-recipes.s3.amazonaws.com/prd/aws-chef-recipes-master.zip
ConfigurationManager:
Name: Chef
Version: "12"
DefaultInstanceProfileArn: !Join
- ''
- - 'arn:aws:iam::'
- !Ref 'AWS::AccountId'
- ':role/DefaultOiServerRole'
ServiceRoleArn: !Join
- ''
- - 'arn:aws:iam::'
- !Ref 'AWS::AccountId'
- ':role/aws-opsworks-service-role'
由于某种原因,DefaultInstanceProfileArn 中的 !Join 声明未按预期工作。尝试创建堆栈时,会引发以下错误。
Default Instance Profile Arn: must be an instance profile ARN belonging to AWS account
解决方案
您正在尝试引用实例配置文件 arn,其格式应为
arn:aws:iam::1234567890:instance-profile/MyProfile-ASDNSDLKJ
- 注意instance-profile
您提供的是一个角色 arn。
推荐阅读
- mysql - 在 MySQL 中 Sequlize 等效的一对多关系
- java - 重用 for 循环的最佳方法是什么?
- dialogflow-es - 如何解决 Dialogflow 轮播卡富响应输入类型中的问题?
- android - 在匿名内部类中获取协程范围引用
- php - php-mongo 与 Arch linux 上的 php 7 不兼容
- angular - 上一页的ngOnInit方法的角度导航问题
- cmake - /usr/lib/x86_64-linux-gnu/libxml2.so:添加符号时出错:文件格式错误
- reactjs - 反应本机比较以前的状态和当前状态数组与 websocket
- google-cloud-platform - 如何根据策略验证 GCR 图像是否经过二进制授权或证明?
- c# - 运算符“*”不能应用于“Vector3”和“Vector3”类型的操作数