handling output of runbook in ssm

0

hello there, I am trying to make a custom runbook in ssm. my custom runbook uses another runbook as one of its steps namely "AWSSupport-CopyEC2Instance". based on AWS documents, the runbook has 3 outputs: "sameRegionLaunchInstanceWithKeyPair.InstanceIds" "sameRegionLaunchInstanceWithoutKeyPair.InstanceIds" "destinationRegionLaunchInstance.DestinationInstanceId" I want to use the second output and pass it to the next step to process. in the first runbook i set the output as: name of output: DestinationInstanceId selector: $.Payload.sameRegionLaunchInstanceWithoutKeyPair.InstanceIds

the problem is that, when I pass it to the next runbook, instead of the value of ec2 instance id, it returns the actual name: "{{ AWSSupport_CopyEC2Instance.DestinationInstanceId }}". what should i do to resolve the problem? please guide me

Aref
질문됨 3달 전130회 조회
1개 답변
0

Dear Customer, Hope you are doing good!!

It seems like you're encountering an issue where the output variable name is being passed instead of its value when using a custom runbook in AWS Systems Manager (SSM).

When referencing the output variable in the subsequent steps of your custom runbook, use the correct syntax to access its value. In AWS Systems Manager Automation documents, you typically use the following syntax to access output variables: {{ OutputName.Payload.VariableName }}.

Replace "OutputName" with the name of the output and "VariableName" with the name of the variable within that output.

In your case, the correct syntax to reference the second output variable would be: {{ AWSSupport_CopyEC2Instance.sameRegionLaunchInstanceWithoutKeyPair.InstanceIds.Payload }}.

I am providing you a sample code for your reference

description: "Custom Runbook"
schemaVersion: "0.3"
parameters:
name: "InstanceId"
    type: "String"
    description: "Instance ID"
    default: ""
mainSteps:
name: "Step1"
    action:
      actionType: "aws:executeScript"
      inputs:
        runCommand:
"echo 'Executing Step 1'"
    name: "Step 1"
name: "Step2"
    action:
      actionType: "aws:executeScript"
      inputs:
        runCommand:
"echo 'Executing Step 2 with Instance ID: {{ InstanceId }}'"
    name: "Step 2"
name: "Step3"
    action:
      actionType: "aws:executeScript"
      inputs:
        runCommand:
"echo 'Executing Step 3 with DestinationInstanceId: {{ AWSSupport_CopyEC2Instance.sameRegionLaunchInstanceWithoutKeyPair.InstanceIds.Payload }}'"
    name: "Step 3" 

Damini
답변함 25일 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠