I am trying to list all the images which has the name Ansible*.
If i can pull it off, i can use it to clean my AMI's that are created during patching activity. i am trying it via SSM Automation Document. below is the code i have.
description: This document is to remove AMI
schemaVersion: '0.3'
assumeRole: '{{ AutomationAssumeRole }}'
mainSteps:
- name: getImageId
action: 'aws:executeAwsApi'
inputs:
Service: ec2
Api: DescribeImages
Filters:
- Name: 'name'
Values:
- 'Ansible*'
outputs:
- Name: ImageId
Selector: '$.Images[0].ImageId'
Type: String
here, Selector: '$.Images[0].ImageId' gives only the 1st image id of the list. i can get it if i can give something like Selector: '$.Images[*].ImageId' but this is not supported by the SSM document.
could someone please help me on this. all i want is, i want to list all the images with its AMI ID.
PS: i have the shell and python script which does the job,. but i am looking for AWS SSM Automation document due to roles and policy restrictions