Code Monkey home page Code Monkey logo

amazon-detective-multiaccount-scripts's Introduction

amazon-detective-multiaccount-scripts

Amazon Detective provides a set of open-source Python scripts in this repository. The scripts require Python 3.

You can use these to perform the following tasks:

  • Enable Detective for an administrator account across Regions. When you enable Detective, you can assign tag values to assign to a new behavior graph.
  • Add member accounts to an administrator account's behavior graphs across Regions.
  • Optionally send invitation emails to the member accounts. You can also configure the request to not send invitation emails.
  • Remove member accounts from an administrator account's behavior graphs across Regions.
  • Disable Detective for an administrator account across Regions. When an administrator account disables Detective, the administrator account's behavior graph in each Region is disabled.

For more information on how to use these scripts, see Using the Amazon Detective Python scripts

Contributing to this project

Complete use case

The following is an example use case of adding multiple accounts in a graph.

  1. Create a .csv file of the AWS account ids.
    1. (Please check the format in section: Creating a .csv list of accounts to add or remove)
  2. Add the necessary permissions to each account.
    1. (Please check the complete setup in section: Required permissions for the scripts)
  3. Add the root module into PYTHONPATH.
    #For example: export PYTHONPATH=$PYTHONPATH:/my_folder/amazon-detective-multiaccount-scripts/src
    
    export PYTHONPATH=$PYTHONPATH:<absolute root module path> 
    
  4. Go to the root module, and run the python script and specify the .csv file. Make sure the role specified by --assume_role is the one created in Step 2.
    #For example:
    cd /my_folder/amazon-detective-multiaccount-scripts/src/amazon_detective_multiaccount_scripts
    python3 enableDetective.py --admin_account 111122223333 --assume_role ManageDetective --input_file inputFile.csv --tags Department=Finance --enabled_regions us-west-1
    
  5. Check results of the script in the terminal and/or AWS console.
    1. For example, for the command above, the terminal should have the following output: plot plot

Running tests

# Install requirements

pip3 install boto3 pytest

# In the tests/ directory...

# Add your root module into PYTHONPATH (if you haven't done this step) 
# eg: export PYTHONPATH=$PYTHONPATH:/my_folder/amazon-detective-multiaccount-scripts/src

export PYTHONPATH=$PYTHONPATH:<absolute root module path> 

# Run the test

pytest -s

FAQs

  1. If you experience the following error Message for opt-in regions while enabling detective in all regions:

    ERROR - error with region <region>: An error occurred (UnrecognizedClientException) when calling the ListGraphs operation: The security token included in the request is invalid

    Using the scripts in opt-in regions assumes you have your accounts/resources configured in that region, so please double-check your accounts' configuration.

    For further information, here is documentation on opt-in regions work: https://docs.aws.amazon.com/general/latest/gr/rande-manage.html.

amazon-detective-multiaccount-scripts's People

Contributors

alaniyonu avatar amazon-auto avatar amazonelizabethzhong avatar macedogm avatar michaelaberman avatar nbkem1 avatar owen-propeller avatar smsilb avatar sonofagl1tch avatar wingamajig avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.