amazon-cloudformation - 参考从先前资源创建的 arn
问题描述
我正在尝试将第一步创建的策略的资源 arn 添加到第二步。但我无法将资源一中的 arn 引用到资源二。我尝试使用!ref 和 getattr,两者都不起作用。有什么解决办法吗?
在我尝试执行的 cloudformation 模板下方。
Parameters:
AccountID:
Type: 'String'
Default: "123465646"
Description: "account id where the resources will be created"
Resources:
ssmPolicyEc2Manage:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: "This policy will be attached to EC2 running ssm agent"
Path: "/"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action: "iam:PassRole"
Resource:
- !Join [ "", [ "arn:aws:iam::", !Ref AccountID, ":role/ssm_role_policy" ] ]
snsPolicyRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect : "Allow"
Principal:
Service :
- "ssm.amazonaws.com"
- "ec2.amazonaws.com"
Action:
- "sts:AssumeRole"
Path: "/"
ManagedPolicyArns:
- "HERE INCLUDE THE RESOURCE ARN CREATED FROM THE PREVIOUS RESOURCE I.E,ssmPolicyEc2Manage "
DependsOn: ssmPolicyEc2Manage
谢谢您的帮助。
解决方案
!Ref ssmPolicyEc2Manage 将返回资源的 ARN。您可以查看文档以更好地理解。
推荐阅读
- sql - 如何将列的子字符串(在一个表中)与另一列的完整值(在另一个表中)连接起来
- sql - 将链接表附加到一个表中?
- api - Service Fabric Web api 返回错误消息:参数无效,代码:E_INVALIDARG
- sql-server - 在 t-sql 中列成数组或逗号分隔列表
- python - 函数的可变对象参数在哪里?有符号表吗?(Python教程4.7.1)
- python - 类型的对象
不是 JSON 可序列化的 - deployment - SCCM 1802 - 计划部署 WOL 不工作,但 RightClickTools WOL 工作
- python - VTK,Python:如何连接 vtkpoints 并将它们可视化为表面?
- sql - 用于查找与一个人关联的相关 ID 的 Oracle 代码
- javascript - 如何使用 getElementByClassName 使文本出现并重新出现在 Javascript 中?