尝试在SSM:Automation文档上进行一些条件分支。
我有一个lambda函数,它可以验证特定条件并在SSM中发布参数。
然后,我想读取参数(使用aws:invokeLambdaFunction)并将该参数用作变量以执行分支(使用aws:branch)。这就是我的方法
我完全被困住了,因此将不胜感激
"Type": "AWS::SSM::Document",
"Properties": {
"DocumentType": "Automation",
"Content": {
"description": "This automation document triggers Golden AMI creation workflow.",
"schemaVersion": "0.3",
"assumeRole": {
"Fn::GetAtt": [
"AutomationServiceRole",
"Arn"
]
},
"parameters":{
the various parameters
},
"mainSteps": [
{
"name": "testUpdateNeeded",
"action":"aws:invokeLambdaFunction",
"timeoutSeconds":1200,
"maxAttempts":1,
"onFailure":"Abort",
"inputs":{
"FunctionName":"arn:aws:lambda:MY_ARN_CODE"
}
},
{
"name":"assertExecutionParameter",
"action":"aws:executeAwsApi",
"maxAttempts":1,
"onFailure":"Abort",
"inputs":{
"Service":"ssm",
"Api":"GetParameter",
"Name":"ssmExecutionParameter"
},
"outputs":{
"Name":"ExecutionParameter",
"Selector":"$.Parameter.Value",
"Type": "String"
}
},
{
"name":"branch",
"action":"aws:branch",
"inputs":{
"Choices":[
{
"NextStep":"lastStep",
"Variable":"assertExecutionParameter.ExecutionParameter",
"StringEquals":"Dont trigger"
}
],
"Default":"startInstances"
}
},
我无法弄清楚如何从API调用中输出返回值。实际上,我不断收到以下错误
`JSON not well-formed. at Line: 1, Column: 2669 (Service: AmazonSSM; Status Code: 400; Error Code: InvalidDocumentContent; Request ID: 142a0482-6065-4715-978c-22ceb6685985)`
指示它不喜欢格式,但是指示错误的行。如果我删除了
"Name":"ExecutionParameter",
"Selector":"$.Parameter.Value",
"Type": "String"
}
然后堆栈更新,但是如果没有上一步的输出,我将无法执行分支步骤。...