# AI SRE AWS integration

Connect AWS to give AI SRE read-only access to the logs, metrics, traces, CloudTrail events and resources of an AWS account during an investigation.

## Connect your AWS account

1. Open [Integrations](https://chat.betterstack.com/team/0/integrations/popular ";_blank") in **AI SRE**.
2. Click **Add** next to **AWS**.
3. Enter your 12-digit **AWS account ID**.
4. Click **Create integration**.
5. Click **Deploy CloudFormation stack**. It opens AWS CloudFormation with Better Stack's template and your integration's parameters filled in.
6. Sign in to the AWS account you entered, as a user who can create IAM roles.
7. Select the acknowledgement that AWS CloudFormation might create IAM resources with custom names.
8. Create the stack.
9. Keep the integration's page open until it shows **AWS account connected**. That takes about a minute once the stack is ready. With the page closed, it can take up to an hour.

Each integration connects one AWS account. Add another integration for every other account.

## What AI SRE can read

Once connected, AI SRE can read:

-   CloudWatch alarms, metrics, log events and Logs Insights queries.
-   X-Ray traces, CloudTrail event history and AWS Health events.
-   Descriptions of your compute, database, networking and messaging resources, such as EC2 instances, ECS services, EKS clusters, RDS databases and load balancers.
-   CloudFormation stacks and the status of their resources.

The [CloudFormation template](https://github.com/BetterStackHQ/aws/blob/main/cloudformation/ai-sre/README.md ";_blank") is open source. It creates one read-only IAM role, `better-stack-ai-sre-role-<8 hex>`, and nothing that runs or stores data.

## Remove the integration

1. In **AI SRE** → [Integrations](https://chat.betterstack.com/team/0/integrations ";_blank"), click the account's ID under **AWS**.
2. Click **Remove**.
3. Confirm. AI SRE stops using the role right away.
4. In AWS CloudFormation, delete the `betterstack-ai-sre-<8 hex>` stack the **AWS integration was successfully removed.** message names. Deleting the stack deletes the role.
