我有一个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.
的{{1}}替换为ARN
,但是我看不到从模板本身中检索此值的任何方法。 The documentation未在mySSMDocument
上指定任何允许获取GetAtt
的{{1}}功能。有人知道如何解决这个问题吗?
答案 0 :(得分:1)
这是文档的ARN模式
arn:$ {Partition}:ssm:$ {Region}:$ {Account}:document / $ {DocumentName}
示例:
arn:aws:ssm:us-east-2:12345678912:document / demoooo
您可以使用Ref
函数获取文档名称,然后使用Sub
创建最终的ARN
答案 1 :(得分:1)