Onboard AWS accounts and organizations with a Python script

After Cloud Security is deployed, you’re ready to start harvesting data from AWS, which requires securely connecting your Amazon Web Services (AWS) Accounts and Organizations to the Rapid7 Command Platform. As visibility into your cloud accounts improves and your inventory grows, you can then begin to leverage the rest of Cloud Security, including Insights, Bots, Layered Context, and more.

You can use a custom Python script (onboard.py) developed by Rapid7 to programmatically create and deploy AWS resources required for Rapid7 to collect data from your unique environment. If you would prefer an alternative onboarding method, see the AWS Overview and Support.

Prerequisites

CLI and software:

  • Python 3.9 or greater
  • AWS CLI configured with appropriate permissions
  • boto3 Python library for AWS API interactions

General:

  • AWS permissions for:
    • IAM role and policy management
    • CloudFormation stack (for single account onboarding) and StackSet (for organization onboarding) operations
    • AWS Organizations (for organization-level deployment only)
    • Basic STS operations (sts:GetCallerIdentity)
  • Cloud Security Domain or Organization Admin permissions
  • Knowledge of AWS terminology and services
Not sure if you have the correct AWS permissions?

You can use the script to check your AWS permissions. Review Common script use cases for details.

Key script terminology

Before you begin, review the core concepts and components that define the AWS onboarding process for Cloud Security:

  • IAM Role: An IAM role is an AWS identity with specific permissions that can be assumed by AWS services, applications, or users. Roles don’t have permanent credentials; instead, they provide temporary security credentials when assumed.
  • IAM Policy: IAM policies are JSON documents that define permissions. There are two main types:
    • Managed Policies: Standalone policies with their own ARN that can be attached to multiple users, groups, or roles
    • Inline Policies: Policies directly embedded in a single user, group, or role
  • Trust Policies (Assume Role Policy): A trust policy defines which entities can assume a role. It’s attached to the role and specifies the trusted principals and conditions.
  • AWS Partitions: AWS operates in different partitions for security and compliance:
    • AWS: Commercial regions (default)
    • AWS_GOV: AWS GovCloud regions (US government)
    • AWS_CHINA: AWS China regions
  • CloudFormation: AWS CloudFormation is a service that helps you model and set up AWS resources using templates. It provides:
    • Stacks: A collection of AWS resources managed as a single unit
    • StackSets: Deploys stacks across multiple accounts and regions
    • Change Sets: Preview changes before applying them to a stack
  • AWS Organizations: AWS Organizations helps you manage multiple AWS accounts centrally. Key concepts:
    • Root Organizational Unit: The top-level container for all accounts
    • Organizational Units (OUs): Logical groupings of accounts
    • Service Control Policies (SCPs): Guardrails for account permissions

Download the script and connect accounts

You can configure and download the script in the Cloud Security Add Cloud Account interface. Adjusting the configuration details and scope changes parameters inside the script, which affects the generated CloudFormation template and IAM policies used to connect the account.

Need to adjust configuration details?

If you need a new configuration, Rapid7 recommends using the Add Cloud Account interface to generate and download a different script.

Script reference

The onboarding script has many options available to simplify, customize, or test the onboarding process. This page does not exhaustively document the options in the script, so use the help (-h, --help) option to see the latest options and what they do.

Many script options are pre-configured

Many options (like --partition) are often pre-configured using environment variables (CHOSEN_ parameters) when running in managed environments, reducing the need for manual CLI specification.

Common script use cases

The most common use cases for the script (excluding onboarding) are as follows:

Advanced script use cases

This section includes some niche, advanced use cases for the onboarding script:

Troubleshooting