By using AWS re:Post, you agree to the Terms of Use

Returning AWS Config aggregator results as CSV

1 minute read
Content level: Intermediate
0

AWS Config aggregator collects resource and compliance information from multiple AWS Accounts and Regions. If you want to fetch results from it as Comma-Separated Values, this command can help.

Prerequisites

  • Install the AWS CLI
  • Install the third-party tool jq
  • Configure suitable AWS credentials and region (or add --region ... to the command below)
  • Find the name of your resource aggregator (in the AWS Config console, choose Aggregators from the menu)

Method

Run the following command in your shell. Replace MY_AGGREGATOR_NAME with the name of your aggregator.

aws configservice select-aggregate-resource-config \
    --expression "SELECT resourceType, resourceId, resourceName" \
    --configuration-aggregator-name MY_AGGREGATOR_NAME \
    --output json | \
jq -r '.Results[] | fromjson | [.resourceType, .resourceId, .resourceName] | @csv'

The command will output a list of CSV entries giving the resource type, id, and name (if available). You can redirect this output to a file, or pipe it in to another program to do further processing.

For more information on the syntax of the query expression, see the documentation. If you modify the fields the query selects, you will need to update the jq command to match them.

EXPERT
published 21 days ago79 views