AWS Terraform Connection
Terraform is an infrastructure-as-code (IaC) tool that automates the provisioning and management of cloud infrastructure.
Use this integration if your organization manages AWS infrastructure with Terraform. Terraform provides an alternative to manually configuring the AWS integration in OX by automatically provisioning the IAM role and permissions required for OX to access your AWS environment and collect cloud security findings securely.
You can use Terraform to connect:
Prerequisites
Before you begin, make sure you have:
Terraform version 1.2.0 or later
Required to deploy the Terraform configuration.
AWS credentials with permission to create IAM roles and policies
Required because the Terraform deployment automatically creates the IAM role and policies that OX uses to access your AWS environment.
External ID from OX
Used when creating the connector role.
Integrating OX with a single AWS Account
Use this method to connect a single AWS account.
To connect a single account:
Download the Terraform file
ox_aws_integration.tf, and save it in an empty directory.Configure AWS credentials for the account you want to connect. Example:
export AWS_ACCESS_KEY_ID="AKIA..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_DEFAULT_REGION="eu-west-1"If you use temporary credentials, also configure AWS_SESSION_TOKEN.
To initialize Terraform, open a terminal in the directory that contains the Terraform file and run:
To deploy the integration, run:
Review the planned changes and enter
yeswhen prompted.
When the deployment completes, Terraform displays the generated ox_role_arn.
To connect AWS in OX, go to Settings > Connectors, and select AWS.
Paste the
ox_role_arnvalue.Select Connect.
The AWS account is connected to OX.
Integrating OX with AWS Organizations
Use this method to connect multiple AWS accounts managed through AWS Organizations.
Deploy the Terraform configuration to each existing member account and to the management account. The deployment creates the required IAM role in every account, allowing OX to collect cloud security findings across the organization.
You can extend the integration with additional capabilities, such as Amazon EKS cluster analysis and Amazon ECR repository analysis.
After completing the deployment, connect the AWS Organizations integration in OX using the Role ARN generated for the management account.
The same External ID and IAM role name must be used across all accounts in the organization.
Before You Begin
Deploy the Terraform configuration to:
Every member account
The management account
The following values must be identical across all accounts:
External ID
IAM role name
Only the AWS credentials change between deployments.
Deploying the Terraform configuration to the management account is required.
To integrate with AWS organization account:
Download the Terraform file
ox_aws_integration_organization.tf, and save it in an empty directory.To initialize Terraform, open a terminal in the directory that contains the Terraform file, and run:
For each member account, configure the account's AWS credentials, create a dedicated Terraform workspace, and deploy the integration. For example:
Repeat this step for each member account.
Configure the management account credentials and deploy the integration. For example:
When the deployment completes, Terraform displays the generated ox_role_arn.
To connect AWS in OX, go to Settings > Connectors, and select AWS.
Paste the
ox_role_arngenerated by the management account deployment.Select Connect.
The AWS Organization is connected to OX.
When connecting AWS Organizations, use the role ARN generated by the management account deployment.
Adding new AWS accounts
New AWS accounts added to the organization are not onboarded automatically.
To connect a new account:
Configure credentials for the new account.
Deploy the Terraform configuration.
Use the same External
IDandIAM rolename used by the existing deployments.
Enable additional AWS monitoring capabilities
By default, the Terraform deployment creates the IAM role required for the AWS integration.
If you also want OX to monitor additional AWS services, configure the corresponding Terraform variables when running the terraform apply command.
Monitor Amazon ECR repositories
ecr_monitoring_enabled
true
Grants OX the permissions required to analyze Amazon ECR repositories.
Monitor Amazon EKS clusters
eks_monitoring_enabled
true
Grants OX the permissions required to analyze Amazon EKS clusters.
Use a custom IAM role name
iam_role_name
OxAWSIntegrationRole
Creates the connector role with a custom name instead of the default.
Example:
The following command replaces the terraform apply command shown earlier. It creates the connector role with a custom IAM role name while enabling Amazon EKS and Amazon ECR monitoring.
You can also store these values in a terraform.tfvars file.
Disconnect AWS
Disconnecting a single AWS account
To remove the integration, run:
Disconnecting AWS Organizations
To disconnect an AWS Organization:
Configure credentials for the account.
Select the account's Terraform workspace.
Run:
Repeat for each member account and the management account.
Make sure the selected Terraform workspace matches the AWS account configured in your credentials.
Last updated
