2回答
- 新しい順
- 投票が多い順
- コメントが多い順
0
Hello ,
From the above problem statement I understand you were facing synatx issue while specifying the property InputTemplate in cloudformation.
The correct syntax would be :
input_template=f'{{"InstanceId": [<instanceid>],"ASGName": [<asgname>],"LCHName": [<lchname>],"automationAssumeRole": ["{cw_event_role.role_arn}"]}}'
Also I would like to provide the full code I tested:
input_transformer_property = events.CfnRule.InputTransformerProperty(
input_paths_map={
"asgname": "$.detail.AutoScalingGroupName",
"instanceid": "$.detail.EC2InstanceId",
"lchname": "$.detail.LifecycleHookName"
},
input_template=f'{{"InstanceId": [<instanceid>],"ASGName": [<asgname>],"LCHName": [<lchname>],"automationAssumeRole": ["{cw_event_role.role_arn}"]}}'
)
Below is synthesized cfn template from cdk synth command:
JSON :
"MyCfnRule": {
"Type": "AWS::Events::Rule",
"Properties": {
"Description": "My event rule",
"ScheduleExpression": "cron(0 0 * * ? *)",
"State": "ENABLED",
"Targets": [
{
"Arn": {
"Fn::GetAtt": [
"HelloHandler2E4FBA4D",
"Arn"
]
},
"Id": "MyTarget",
"InputTransformer": {
"InputPathsMap": {
"asgname": "$.detail.AutoScalingGroupName",
"instanceid": "$.detail.EC2InstanceId",
"lchname": "$.detail.LifecycleHookName"
},
"InputTemplate": {
"Fn::Join": [
"",
[
"{\"InstanceId\": [<instanceid>],\"ASGName\": [<asgname>],\"LCHName\": [<lchname>],\"automationAssumeRole\": [\"",
{
"Fn::GetAtt": [
"cweventroleid23238EBB2881",
"Arn"
]
},
"\"]}"
]
]
}
}
}
]
}
Yaml :
MyCfnRule:
Type: 'AWS::Events::Rule'
Properties:
Description: My event rule
ScheduleExpression: cron(0 0 * * ? *)
State: ENABLED
Targets:
- Arn: !GetAtt
- HelloHandler2E4FBA4D
- Arn
Id: MyTarget
InputTransformer:
InputPathsMap:
asgname: $.detail.AutoScalingGroupName
instanceid: $.detail.EC2InstanceId
lchname: $.detail.LifecycleHookName
InputTemplate: !Join
- ''
- - >-
{"InstanceId": [<instanceid>],"ASGName":
[<asgname>],"LCHName": [<lchname>],"automationAssumeRole": ["
- !GetAtt
- cweventroleid23238EBB2881
- Arn
- '"]}'
回答済み 9ヶ月前
関連するコンテンツ
- AWS公式更新しました 1年前
- AWS公式更新しました 1年前