Files
aws.ssm.documents/OrgAccountsPrint.yaml
T
2026-01-29 09:47:49 +08:00

34 lines
914 B
YAML

schemaVersion: '0.3'
mainSteps:
# Using executeAwsApi, I can get a list[str] which can then be iterated by aws:loop
- name: ListAccounts
action: aws:executeAwsApi
nextStep: Loop
isEnd: false
inputs:
Service: organizations
Api: ListAccounts
outputs:
- Type: StringList
Name: Accounts
Selector: $.Accounts..Id
- name: Loop
action: aws:loop
isEnd: true
inputs:
Iterators: '{{ ListAccounts.Accounts }}'
IteratorDataType: StringList
Steps:
- name: PrintInput
action: aws:executeScript
isEnd: true
inputs:
Runtime: python3.11
Handler: script_handler
InputPayload:
accountId: '{{Loop.CurrentIteratorValue}}'
Script: |
def script_handler(events,context):
return {"accountId": events.get('accountId')}