> For the complete documentation index, see [llms.txt](https://docs.seemoredata.io/external-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seemoredata.io/external-docs/fundamentals/getting-set-up/setting-integrations/databricks/cloud-cost/aws-permissions.md).

# AWS billing permissions

Review the AWS role, bucket policy, and optional KMS access used by an AWS integration.

Use this reference with the [AWS billing setup guide](https://docs.seemoredata.io/external-docs/fundamentals/getting-set-up/setting-integrations/databricks/cloud-cost/aws.md). The CloudFormation template creates the read-only role. These JSON examples show the expected permissions for review; when you deploy, use the template and values that your AWS integration shows.

Replace every `<PLACEHOLDER>` before using an example. Keep unrelated statements in existing bucket and KMS key policies.

| Placeholder                 | Value                                                                                                                                  |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `<SEEMORE_READER_ROLE_ARN>` | `SeemoreReaderRoleArn` from the stack parameters that SeeMore Data shows: the SeeMore Data reader role that your read-only role trusts |
| `<EXTERNAL_ID>`             | `ExternalId` from the same AWS integration                                                                                             |
| `<BUCKET_NAME>`             | `BucketName` from the same AWS integration                                                                                             |
| `<BILLING_ACCOUNT_ID>`      | The billing account: the AWS account that owns the export and the bucket                                                               |
| `<READ_ONLY_ROLE_ARN>`      | The stack's `RoleArn` output: your read-only role                                                                                      |
| `<KMS_KEY_ARN>`             | The customer-managed key ARN supplied as `KmsKeyArn`, if applicable                                                                    |

## Role trust policy

Your read-only role trusts one specific SeeMore Data reader role, and only with this AWS integration's external ID. It does not trust every identity in the SeeMore Data AWS account.

The external ID stops another SeeMore Data customer from using SeeMore Data to reach your role, even if they learn its ARN. AWS calls this the [confused deputy problem](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html). The external ID is not a secret.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "AWS": "<SEEMORE_READER_ROLE_ARN>" },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": { "sts:ExternalId": "<EXTERNAL_ID>" }
      }
    }
  ]
}
```

## Role permissions

Your read-only role can find the bucket's region, list the `seemore/` folder, and read its files. It cannot write or delete objects. The template attaches this policy to the role:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListReportFiles",
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::<BUCKET_NAME>",
      "Condition": {
        "StringLike": { "s3:prefix": ["seemore/*"] }
      }
    },
    {
      "Sid": "ReadBucketRegion",
      "Effect": "Allow",
      "Action": "s3:GetBucketLocation",
      "Resource": "arn:aws:s3:::<BUCKET_NAME>"
    },
    {
      "Sid": "ReadReportFiles",
      "Effect": "Allow",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::<BUCKET_NAME>/seemore/*"
    }
  ]
}
```

When you supply `KmsKeyArn`, the template also adds this statement to the role policy:

```json
{
  "Sid": "DecryptReportFiles",
  "Effect": "Allow",
  "Action": "kms:Decrypt",
  "Resource": "<KMS_KEY_ARN>"
}
```

## Bucket delivery policy <a href="#bucket-delivery-policy" id="bucket-delivery-policy"></a>

This policy lets AWS deliver reports to the bucket. For a new bucket, the stack creates it. For an existing bucket, the stack does not change the bucket policy. Before you deploy the stack, add the two statements that SeeMore Data shows at the top of **1. Deploy the stack in billing account**. The policy looks like this:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowDataExportsToCheckTheBucket",
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "bcm-data-exports.amazonaws.com",
          "billingreports.amazonaws.com"
        ]
      },
      "Action": ["s3:GetBucketAcl", "s3:GetBucketPolicy"],
      "Resource": "arn:aws:s3:::<BUCKET_NAME>",
      "Condition": {
        "StringEquals": { "aws:SourceAccount": "<BILLING_ACCOUNT_ID>" },
        "ArnLike": {
          "aws:SourceArn": "arn:aws:bcm-data-exports:us-east-1:<BILLING_ACCOUNT_ID>:export/*"
        }
      }
    },
    {
      "Sid": "AllowDataExportsToWriteTheReport",
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "bcm-data-exports.amazonaws.com",
          "billingreports.amazonaws.com"
        ]
      },
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::<BUCKET_NAME>/*",
      "Condition": {
        "StringEquals": { "aws:SourceAccount": "<BILLING_ACCOUNT_ID>" },
        "ArnLike": {
          "aws:SourceArn": "arn:aws:bcm-data-exports:us-east-1:<BILLING_ACCOUNT_ID>:export/*"
        }
      }
    }
  ]
}
```

The write statement covers the whole bucket because AWS writes a test file to the bucket root. Your read-only role can still read only the `seemore/` folder. Both statements allow only exports from your own AWS account. See [AWS report delivery policies](https://docs.aws.amazon.com/cur/latest/userguide/dataexports-s3-bucket.html).

## Existing buckets with KMS encryption

When you supply a key ARN, the stack gives your read-only role `kms:Decrypt` for that key. It does not change your KMS key policy. If the key policy does not already allow IAM permissions, your key administrator can add this statement to the key policy's existing `Statement` list **after the stack has created your read-only role**:

```json
{
  "Sid": "AllowCloudCostReaderToDecrypt",
  "Effect": "Allow",
  "Principal": { "AWS": "<READ_ONLY_ROLE_ARN>" },
  "Action": "kms:Decrypt",
  "Resource": "*"
}
```

In a KMS key policy, `Resource: "*"` means the key to which the policy is attached. It does not grant access to every KMS key. See [AWS KMS key policies](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-overview.html).

This statement lets your read-only role read encrypted reports. Your key administrator must also let AWS Data Exports use the key to write reports. S3 encryption requires `kms:GenerateDataKey` for uploads and can also require `kms:Decrypt` for multipart uploads; see [S3 SSE-KMS permissions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html). Do not replace your key's administrative permissions with this reader statement.

If you do not need a KMS-encrypted bucket, do not select **Use an existing S3 bucket**, so that the stack creates a new bucket. It uses S3-managed encryption and needs no KMS policy changes.
