duo-labs / cloudmapper

CloudMapper helps you analyze your Amazon Web Services (AWS) environments.
BSD 3-Clause "New" or "Revised" License
5.96k stars 800 forks source link

Automatic discovery of AWS Organization member accounts to config.json (closes #757) #758

Closed christophetd closed 3 years ago

christophetd commented 4 years ago

c.f. #757. Tested on my AWS Organization (test account).

Sample run when no config.json exists:

$ python cloudmapper.py configure discover-organization-accounts
Config file does not exist, creating one
INFO:botocore.credentials:Found credentials in environment variables.

$ cat config.json
{
    "accounts": [
        {
            "id": "0xx9",
            "name": "master"
        },
        {
            "id": "7xx4",
            "name": "dev"
        },
        {
            "id": "4xx1",
            "name": "prod"
        },
        {
            "id": "6xx0",
            "name": "logging"
        },
        {
            "id": "4xx7",
            "name": "security"
        }
    ],
    "cidrs": {}
}

Example run when config.json exists, but with none of the accounts of the organization:

$ cat config.json
{
    "accounts": [
        {
            "id": "111",
            "name": "idontexist"
        }
    ],
    "cidrs": {}
}

$ cloudmapper.py configure discover-organization-accounts

$ cat config.json
{
    "accounts": [
        {
            "id": "111",
            "name": "idontexist"
        },
        {
            "id": "0xx9",
            "name": "master"
        },
        {
            "id": "7xx4",
            "name": "dev"
        },
        {
            "id": "4xx1",
            "name": "prod"
        },
        {
            "id": "6xx0",
            "name": "logging"
        },
        {
            "id": "4xx7",
            "name": "security"
        }
    ],
    "cidrs": {}
}
CLAassistant commented 4 years ago

CLA assistant check
All committers have signed the CLA.

christophetd commented 3 years ago

@0xdabbad00 Let me know if you have some interest in this PR, thanks!

0xdabbad00 commented 3 years ago

LGTM, this is great, thank you @christophetd. This can be merged @jordan-wright @kylelady