1 Answer
- Newest
- Most votes
- Most comments
0
Hi,
As per the AWS documentation currently the Iterators supports only StringList type.
https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-action-loop.html
I tried below SSM document and it worked fine for me. Please try and let me know if any issues.
Note: Need to escape the comma in the input parameter with backslash
SSM document:.
description: Automation to loop over a list of string maps
schemaVersion: '0.3'
assumeRole: '{{ AutomationAssumeRole }}'
parameters:
AutomationAssumeRole:
type: String
description: (Optional) The ARN of the role that allows Automation to perform the actions on your behalf.
default: ''
StringMapList:
type: StringList
description: List of string maps to iterate over
default:
- '{"key1": "value1"\, "key2": "value2"}'
- '{"key1": "value3"\, "key2": "value4"}'
mainSteps:
- name: loopOverStringMaps
action: aws:loop
isEnd: true
inputs:
Iterators:
- '{{ StringMapList }}'
Steps:
- name: printStringMap
action: aws:executeScript
isEnd: true
inputs:
Runtime: python3.9
Handler: script_handler
Script: |-
import json
def script_handler(events, context):
string_map = events['IteratorValue']
print(f"Current string map: {string_map}")
InputPayload:
IteratorValue: '{{ loopOverStringMaps.CurrentIteratorValue }}'
answered 2 months ago
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago