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
asked 10 months ago307 views
2 Answers
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
answered 10 months ago
0

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

Thanks for reaching out.

Kal
answered 10 months ago
  • Great! My pleasure!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions