私が作成し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.
とARN
のmySSMDocument
、しかし私は、テンプレート自体の中からこの値を取得する方法が表示されません。ドキュメントには、を取得できる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
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加