gpt4 book ai didi

amazon-web-services - 如何在CloudFormation中获取SSM文档的ARN?

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

我有一个 CloudFormation 模板,它创建 AWS::Events::Rule和一个AWS::SSM::Document 。我需要提供 Targets 的列表对于SSM::Rule ,但每个目标都期望 ARN :

mySSMDocument:
Type: AWS::SSM::Document
Properties:
DocumentType: 'Command'
Content:
schemaVersion: '2.2'
description: "Code that will be run on EC2"
mainSteps:
- action: "aws:runShellScript"
name: runShellScript
inputs:
runCommand:
- 'Some command to execute'
myEventRule:
Type: AWS::Events::Rule
Properties:
Description: "A description for the Rule."
EventPattern:
source:
- "aws.autoscaling"
detail-type:
- "EC2 Instance-terminate Lifecycle Action"
detail:
AutoScalingGroupName:
- !Ref 'someAutoScalingGroupInThisTemplate'
RoleArn: 'some role ARN'
State: "ENABLED"
Targets:
- Id: "some-unique-id"
Arn: <-- This is the value that I need to fill in.
RunCommandParameters:
RunCommandTargets:
- Key: "tag: Name"
Values:
- 'The name of the EC2 machine'

我认为我需要更换 <-- This is the value that I need to fill in.ARNmySSMDocument ,但我没有看到任何方法可以从模板本身中检索该值。 The documentation未指定任何 GetAtt SSM::Document 上的功能允许获取 ARN 。有谁知道如何解决这个问题吗?

最佳答案

这是文档的 ARN 模式

arn:${Partition}:ssm:${Region}:${Account}:document/${DocumentName}

示例:

arn:aws:ssm:us-east-2:12345678912:document/demoooo

您可以使用Ref函数获取文档名称,然后使用Sub创建最终的ARN

引用:https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awssystemsmanager.html#awssystemsmanager-resources-for-iam-policies

关于amazon-web-services - 如何在CloudFormation中获取SSM文档的ARN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59352785/

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