Search code examples
jsonaws-cliaws-config

AWS ConfigService- how to append account IDs


I am trying to append the list of account Ids since I don't have access to organization, but whenever i am doing it, previous accounts get replaced with new account ID and i only want to append them. Please let me know how to do it.

aws configservice put-configuration-aggregator --configuration-aggregator-name test-config --account-aggregation-sources "[{\"AccountIds\": [\"xxxxxx\",\"xxxx\"],\"AwsRegions\": [\"us-east-1\"]}]"

Solution

  • From the documentation

    accountIds that are passed will be replaced with existing accounts. If you want to add additional accounts into the aggregator, call DescribeAggregator to get the previous accounts and then append new ones.

    References : https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configservice/put-configuration-aggregator.html

    So you can first call DescribeAggregator1 to get the previous accounts and store them in some variable. Then append new accounts to previous accounts variable via jq.

    Append JSON Object via jq

    Note - I have added links for AWS CLI V2.