SSM Documents - using output data from a lambda step for another lambda step

0

I have a SSM document which has its first step to call a Lambda function (getLaunchTemplateData) using "action 'aws:invokeLambdaFunction'". The lambda function returns a set of data which is displayed on the "Output payload" on that steps results.... { "Payload": { "LaunchtemplateID": "lt-00972d7c12345678a" }, "StatusCode": 200 }

I'd like to use that output data for a step further below in the document. How can this be achieved?

I have tried adding the "outputs" tag on the 1st step using.. outputs: - Name: LaunchtemplateID Selector: $.Payload.LaunchTemplateID Type: String

Then using this as the payload for the next step which is another Lambda function...

Payload: '{ "LTID": "{{ getLaunchTemplateData.LaunchtemplateID }}" }'

but i receive this message...

{"FunctionError":"Unhandled","Payload":{"errorMessage": "An error occurred (InvalidLaunchTemplateId.Malformed) when calling the CreateLaunchTemplateVersion operation: The specified launch template ID '{{ getLaunchTemplateData.LaunchtemplateID }}' is malformed."

The Input parameters for the step that fails is not picking up the values..

"{"LTID":"{{ getLaunchTemplateData.LaunchtemplateID }}"}"

Kal
已提問 1 年前檢視次數 350 次
2 個答案
2

Hi,

Are the outputs of your Lambda step defined exactly as you referenced in your question?

{ "Payload": { "LaunchtemplateID": "lt-00972d7c12345678a" }, "StatusCode": 200 }
outputs:
  - Name: LaunchtemplateID
    Selector: $.Payload.LaunchTemplateID Type: String

If so, double check that you're using the proper case and variable naming. If the payload output is LaunchtemplateID the outputs selector should also use the lower-case t in Template (ie. $.Payload.LaunchtemplateID not $.Payload.LaunchTemplateID

AWS
已回答 1 年前
0

Yes exactly right. It was the lowercase "t".

Thanks for reaching out.

Kal
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南