> For the complete documentation index, see [llms.txt](https://integrations.drivetrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://integrations.drivetrain.ai/integration-guide/integrate-with-drivetrain/databases-and-warehouses/integrating-with-aws-cost-explorer.md).

# Integrating with AWS Cost Explorer

### Overview

This guide provides step-by-step instructions for connecting AWS Cost Explorer to Drivetrain so your cloud cost and usage data can be synced for analysis and reporting.

### Prerequisites

To connect AWS Cost Explorer to Drivetrain, you need:

* An AWS account with Cost Explorer enabled
* IAM permissions to create policies and roles (or an IAM user) in that account
* The data scope you want to sync (see "Data Scope to Confirm" at the end of this guide)

### Integration Methods

Two approaches are available:

Method 1: IAM Role (Recommended, more secure)

* You grant Drivetrain's AWS account permission to assume a read-only role in your account. No long-lived keys are shared.
* You share back: Role ARN

Method 2: Access Key and Secret

* You create an IAM user with read-only Cost Explorer access and share its credentials.
* You share back: Access key, Access secret

AWS Cost Explorer is a global service, so no AWS Region is required.

### Method 1: Using IAM Role (Recommended)

#### Step 1: Create an IAM Policy

Create the policy in the AWS IAM console with this JSON configuration:

{\
&#x20;   "Version": "2012-10-17",\
&#x20;   "Statement": \[\
&#x20;       {\
&#x20;           "Effect": "Allow",\
&#x20;           "Action": \[\
&#x20;               "ce:GetCostAndUsage",\
&#x20;               "ce:GetCostAndUsageWithResources",\
&#x20;               "ce:GetDimensionValues",\
&#x20;               "ce:GetTags",\
&#x20;               "ce:GetCostForecast",\
&#x20;               "ce:GetCostCategories",\
&#x20;               "ce:ListCostCategoryDefinitions"\
&#x20;           ],\
&#x20;           "Resource": "\*"\
&#x20;       }\
&#x20;   ]\
}

Name the policy "Drivetrain-CostExplorer-Access".

#### Step 2: Create an IAM Role

1. Go to Roles and select Create role
2. Choose AWS account and enter Drivetrain's Account ID: 865992467666
3. Select the "Drivetrain-CostExplorer-Access" policy
4. Name the role "Drivetrain-Integration" and create it

The role's trust relationship should allow Drivetrain's account to assume it. After creation, the trust policy should look like this:

{\
&#x20;   "Version": "2012-10-17",\
&#x20;   "Statement": \[\
&#x20;       {\
&#x20;           "Effect": "Allow",\
&#x20;           "Principal": {\
&#x20;               "AWS": "arn:aws:iam::865992467666:role/Drivetrain-Integration"\
&#x20;           },\
&#x20;           "Action": "sts:AssumeRole"\
&#x20;       }\
&#x20;   ]\
}

#### Step 3: Integration Details

Share these with Drivetrain:

1. Role ARN (e.g. arn:aws:iam::\<your-account-id>:role/Drivetrain-Integration)
2. The data scope (see "Data Scope to Confirm" below)

### Method 2: Using Access Key and Secret

#### Step 1: Create an IAM Policy

Follow the same steps as Method 1, Step 1, to create the "Drivetrain-CostExplorer-Access" policy.

#### Step 2: Create User

1. Go to Users and select Add users
2. Enter a username (e.g. "Drivetrain-Integration")
3. Select "Attach policies directly" and choose your "Drivetrain-CostExplorer-Access" policy
4. Complete user creation

#### Step 3: Generate Access Key and Secret

1. Open the created user in the Users tab
2. Navigate to Security credentials > Access keys
3. Create an access key for third-party service use
4. Copy both the Access key and Secret access key values

#### Step 4: Integration Details

Share these with Drivetrain:

1. Access key
2. Access secret
3. The data scope (see "Data Scope to Confirm" below)

### Data Scope to Confirm

Along with access, confirm what you would like Drivetrain to pull:

* Cost metric(s): unblended, blended, amortized, net amortized, or net unblended cost (and usage quantity, if needed)
* Granularity: daily or monthly
* Group-by dimensions: e.g. service, linked account, region, usage type, instance type
* History: how far back to backfill (e.g. last 12 or 24 months)

### Information to Share with Drivetrain

Provide your Data Integration Manager or Customer Success Manager with:

* Role ARN (Method 1) or Access key and Access secret (Method 2)
* Cost metric(s)
* Granularity
* Group-by dimensions
* History / backfill period


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://integrations.drivetrain.ai/integration-guide/integrate-with-drivetrain/databases-and-warehouses/integrating-with-aws-cost-explorer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
