/amazon-guardduty-multiaccount-scripts

This script automates the process of running the GuardDuty multi-account workflow across a group of accounts that are in your control

Primary LanguagePythonApache License 2.0Apache-2.0

amazon-guardduty-multiaccount-scripts

These scripts automate the process of enabling and disabling Amazon GuardDuty simultaneously across a group of AWS accounts that are in your control. (Note, that you can have one master account and up to a 1000 member accounts).

enableguardduty.py will enable GuardDuty, send invitations from the master account and accept invitations in all member accounts. The result will be a master account that contains all security findings for all member accounts. Since GuardDuty is regionally isolated, findings for each member account will roll up to the corresponding region in the master account. For example, the us-east-1 region in your GuardDuty master account will contain the security findings for all us-east-1 findings from all associated member accounts.

Prerequisites

  • The scripts depend on a pre-existing role that can be utilized within each account. The StackSets service role AWSCloudFormationStackSetExecutionRole is utilized by default. Instructions can be found here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-prereqs.html to setup the role in each account
  • CSV file for accounts to be added in the format of AccountId, Email, ...
  • Master AccountId for all accounts within the CSV file to be linked to

Steps

1. Setup execution environment:

Option 1: Launch EC2 instance:

Option 2: Locally:

2. Execute Scripts

2a. Enable GuardDuty

  • Copy the required CSV file to this directory
    • Should be in the formation of "AccountId,EmailAddress,..."
usage: python enableguardduty.py [-h] [--master_account MASTER_ACCOUNT]
                                 [--assume_role ASSUME_ROLE]
                                 input_file

Link AWS Accounts to central GuardDuty Account

positional arguments:
  input_file            Path to CSV file in the format of accountId, email,
                        ...

optional arguments:
  -h, --help            show this help message and exit
  --master_account MASTER_ACCOUNT
                        AccountId for Central AWS Account
  --assume_role ASSUME_ROLE
                        Role Name to assume in each account

2b. Disable GuardDuty

  • Copy the required CSV file to this directory
    • Should be in the formation of "AccountId,EmailAddress,..."
usage: disableguardduty.py [-h] [--master_account MASTER_ACCOUNT]
                           [--assume_role ASSUME_ROLE] [--delete_master]
                           input_file

Link AWS Accounts to central GuardDuty Account

positional arguments:
  input_file            Path to CSV file in the format of accountId, email,
                        ...

optional arguments:
  -h, --help            show this help message and exit
  --master_account MASTER_ACCOUNT
                        AccountId for Central AWS Account
  --assume_role ASSUME_ROLE
                        Role Name to assume in each account
  --delete_master       Delete the master Gd Detector