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
回答済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ