AWS CloudTrail Integration
AWS CloudTrail is a service that continuously monitors your AWS account activity and records events. It tracks user activity, API usage, and changes to your AWS resources, so that you have visibility into the actions being taken on your account. CloudTrail stores the information, like who made the request, the services used, the resource accessed, and actions that were taken. You can view, search, and download this information from your CloudTrail console.
To help you store, track, and respond to events, you can create trails from your console, the AWS CLI, or the CloudTrail API. The goal is to streamline your event history, so that you can oversee your AWS infrastructure and ensure compliance with your company policies and regulatory standards.
You can set up AWS CloudTrail to stream your AWS account activity directly into InsightOps. With the integration, you can use InsightOps to search your AWS account activity for specific actions, users who initiated specific actions, and resources impacted by them.
To set up the AWS CloudTrail integration, you’ll need to:
- Enable AWS CloudTrail.
- Create a new trail.
- Create an SQS queue and subcribe it to the SNS topic.
- Set up the privacy and trust relationship for the IAM policy and role.
- Add the integration in InsightOps.
Enable AWS CloudTrail
AWS CloudTrail is automatically enabled when an AWS account is created. All activity is recorded as an event and archived for 90 days. To help you store, analyze, and manage changes to your AWS resources, and extend the record of events beyond 90 days, you can create a CloudTrail trail.
Create a Trail
A trail is a long-term record of your AWS account activity. It allows you to filter and continuously deliver the trail’s log files to an Amazon S3 bucket, which will be sent to InsightOps.
In order to set up the AWS CloudTrail integration with InsightOps, you will need to create a new trail.
Learn More About Creating Trails
For a deeper dive and more comprehensive instructions on CloudTrail trails, read the AWS documentation.
To create a trail:
- Log in to your AWS Management Console using your IAM user configured for CloudTrail administration. You’ll need to specify the region where you want to create your trail.
- From the navigation pane, go to CloudTrail > Trails > Create new trail.
- In the Trail name field, enter a descriptive name that helps you easily identify the purpose of the trail.
- In the Storage Location section, choose whether you want to create a new Amazon S3 bucket or use an existing one, and then follow the instructions. The S3 bucket will be used to store your CloudTrail logs.
- After you specify your S3 bucket, click the Advanced link to expand the menu.
- Find the Send SNS notification for every log file delivery option and select Yes.
- To create a new SNS topic, select Yes for the Create a New SNS topic option. Otherwise, to use an existing SNS topic, select No and choose the SNS topic you want to use from the dropdown.
- Create the trail.
Create an Amazon SQS Queue and Subscribe to the SNS Topic
After you create a trail, you’ll need to:
Step 1: Create an Amazon SQS queue
- Log in to your AWS Management Console.
- Go to the Simple Queue Service console and click the Create New Queue button.
- On the Create New Queue page, verify that you have the correct region selected, and enter a name in the Queue Name field.
- Choose the type of queue you want to create, which will determine the order and delivery of the messages : standard or First-In-First-Out (FIFO).
- Click Quick-Create to create the queue with default parameters.
Your new queue will be available from the queue list, and you can subscribe the SNS topic you specified for your trail to it.
Step 2: Subscribe an Amazon SQS queue to the SNS topic
- Log in to your AWS Management Console and go to the Simple Queue Service console .
- From the list of queues, select the queue you want to which you want to subscribe an SNS topic.
- Click the Queue Actions dropdown and choose Subscribe Queue to SNS Topic from the menu.
- From the Subscribe to a Topic window, click the Choose a Topic dropdown and select the 6. SNS topic you want to subscribe to. Make sure you’re choosing the topic you specified for your trail.
- Subscribe the queue to the topic.
Create and Configure Your IAM Policy and Role
Access to AWS is managed through IAM policies that are attached to IAM identities or AWS resources. An IAM policy defines the permissions for an identity, like a role or user, or an AWS resource. These policies are used to assess whether requests are allowed or denied.
To give an account access and permissions to an SNS topic and SQS queue, you’ll need to:
Step 1: Create an IAM policy
- Log in to your AWS Management Console and go to the IAM console .
- From the left menu, choose Policies and choose Create policy.
- Set up a policy that grants permissions to the SQS queue you set up earlier and the Amazon S3 bucket you created to to store your CloudTrail logs.
- Configure your S3 permissions to be List and Read.
- Configure your SQS queue permissions to be List, Read, and Write.
- Create the policy.
Now you’re ready to create an IAM role and attach this policy to it.
Step 2: Create an IAM role
- Log in to your AWS Management Console and go to the IAM console .
- From the left menu, choose Roles and choose Create role.
- When the Create Role page appears, choose the Another AWS account role type option as your trusted entity type.
- Enter the account ID you want to grant access to your resources to.
- Click Next: Permissions. On the Permissions section, attach the IAM policy you created earlier.
- Click Next: Review. On the Review section, enter a name and description for the role. You will also see the policy attached to the role.
- Create the role. It will be listed in the roles table.
- From the roles table, find and click the role you just created to open the Summary page.
- Go to the Trust relationships tab and click Edit Trust Relationship.
- In the Trust Relationship policy document, you’ll need to update the AWS account in the Principal element to include the following Rapid7 ID:
336818582268
. Your policy document might look like:
1{2"Version": "2012-10-17",3"Statement": {4"Effect": "Allow",5"Principal": {"AWS": [6"arn:aws:iam::336818582268:root",7]},8"Action": "sts:AssumeRole"9}10}
- From the Trust Relationships tab, you will also need to set up an external ID that serves as an extra authentication layer. Select the Require external ID option. The external ID can be any word or number. You just need to remember it when you set up the integration from InsightOps.
- Apply your changes.
You’ll need the name of the IAM role you created when you set up the CloudTrail integration with InsightOps.
Add the CloudTrail Integration in InsightOps
- Log in to InsightOps.
- From the left menu, choose Data Collection.
- When the Add Data Source page appears, click CloudTrail Integrations.
- Click the Add New Integration button.
- When the AWS CloudTrail panel appears, enter a name and description for the integration. Click Next to continue.
- Under the Logs section, choose the destination log and log set you want to use to view your CloudTrail logs. Click Next to continue.
- Under the AWS section, enter the following information:
- AWS Account ID - To locate your account ID, log in to your AWS Management Console and go to your IAM console.
- SQS Queue URL - To find your SQS Queue URL, log in to your AWS Management Console and go to your Simple Queue Service console. You can find the URL on the Details tab.
- IAM role name - To find a list of available IAM roles, log in to your AWS Management Console and go to your IAM console. From the left menu, choose Roles. The resulting table will display all of the roles available.
- IAM role external ID - The external ID designates that InsightOps can assume to role. You can find the external ID in the Trust Relationship policy document. The format will be: “sts”: ”ExternalID”.
- Create the integration.
After you successfully add the integration, you will see it listed under the System Data section on the Add Data Source page. You'll be able to choose it as a source for sending data.