Last active
November 20, 2024 14:39
-
-
Save atheiman/950cccf2c0c3fb98a09e2ae20b37d205 to your computer and use it in GitHub Desktop.
Get all EC2 instances from an AWS Config Aggregator using AWS CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# batch-get-aggregate-resource-config only accepts 100 resource identifiers. If you need to get the configuration | |
# of more items, use python + boto3: https://gist.github.com/atheiman/9830de25a3fb54a06b86953a2675bbd1 | |
AGGREGATOR_NAME='MyConfigAggregator' | |
aws configservice batch-get-aggregate-resource-config \ | |
--configuration-aggregator-name "$AGGREGATOR_NAME" \ | |
--resource-identifiers "$( | |
aws configservice list-aggregate-discovered-resources \ | |
--configuration-aggregator-name "$AGGREGATOR_NAME" \ | |
--resource-type 'AWS::EC2::Instance' \ | |
--query 'ResourceIdentifiers' | |
)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful, thank you. I piped it into
jq
to break down the nested JSON string inside. In this case checkingstate
and flattening the tags list out:Result: