gpt4 book ai didi

aws-cloudformation - 引用从先前资源创建的 arn

转载 作者:行者123 更新时间:2023-12-03 07:19:11 27 4
gpt4 key购买 nike

我正在尝试将从第一步创建的策略的资源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。你可以看看documentation为了更好地理解。

关于aws-cloudformation - 引用从先前资源创建的 arn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57264204/

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