# Set Up Access Summary Export

{% hint style="info" %}
**Private preview**

The access summary export is currently in private preview and is available to select accounts. Contact your Immuta representative for details.
{% endhint %}

Use the following how-to to configure the access summary export to an S3 bucket. This export configuration requires access to your S3 bucket to add objects using one of the following authentication methods:

* [Access and secret key](#how-to-export-using-an-iam-user-with-access-key)
* [AWS IAM role](#how-to-export-using-an-aws-iam-role)

## **Requirements**:

* `GOVERNANCE` Immuta permission
* An S3 bucket you want to use to store the exported access summary.

## How to export using an IAM user with access key

Configure your Immuta access summary to export to your S3 bucket and allow Immuta to authenticate using your AWS access key ID and secret access key. Here's a visual representation of the authentication flow:

<figure><img src="/files/4D8lYpIKDwOa0D20gDF4" alt=""><figcaption></figcaption></figure>

### 1 - Configure an IAM user and policy

Access keys are tied to [IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html), which must be allowed to deposit objects in the target bucket via an attached [IAM policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html). Immuta requires that the user it authenticates as has the following permissions:

* [s3:PutObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html): Allows Immuta to upload objects to the bucket.
* s3:ListBucket: Allows Immuta to use [ListObjectsV2](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html).

If your S3 bucket is encrypted, the following permissions must also be granted to the role:

* [kms:Decrypt](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html#aws-managed-customer-managed-keys): Allows Immuta to verify the integrity of the new data key before using it.
* [kms:GenerateDataKey](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html#aws-managed-customer-managed-keys): Allows Immuta to generate a key that is used to encrypt the objects that are exported to S3 using your KMS key.

To begin, create an IAM user and attach a policy with the above permissions.

1. Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html) to create a new user for Immuta to authenticate as and add objects to your S3 bucket.
2. Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html) for creating IAM policies in the Amazon S3 console for the new policy.

   Here is an example IAM policy that contains the required permissions for a KMS encrypted bucket. **If you are not using KMS encryption, you may omit the second statement**. If you use this example, replace the **content in angle brackets** with the [**Amazon Resource Names (ARNs)**](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) for your **S3 bucket** and **KMS key**:

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:ListBucket"
            ],
            "Resource": "<your-s3-bucket-arn>/*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt",
                "kms:GenerateDataKey"
            ],
            "Resource": "<your-kms-key-arn>"
        }
    ]
}
```

3. Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_change-permissions.html#users_change_permissions-add-console) to attach the policy to your newly created user.
4. Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) to generate the credentials that will be used to configure the export.

### 2 - Create an S3 bucket policy for the export

Before Immuta can export the access summary to your S3 bucket using your configured IAM user, you need to create a bucket policy that allows that IAM user to add objects to your specified S3 bucket. The following Amazon S3 action must be granted in the bucket policy:

* [s3:PutObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html): Allows Immuta to upload objects to the bucket.

To create the policy for the bucket, you must be the bucket owner.

1. Follow [AWS documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html) for adding a bucket policy in the Amazon S3 console.
2. Edit the JSON in the **Policy** section to include a bucket policy like the example below.

   In this example, the policy allows an IAM user (the [principal](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-bucket-user-policy-specifying-principal-intro.html)) to add objects to the bucket. If you use this example, replace the **content in angle brackets** with the [**Amazon Resource Names (ARNs)**](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) for your **IAM user** and **S3 bucket**.

   ```json
   {
       "Version": "2012-10-17",
       "Statement": [
           {
               "Effect": "Allow",
               "Principal": {
                   "AWS": "<your-iam-user-arn>"
               },
               "Action": "s3:PutObject",
               "Resource": [
                   "arn:aws:s3:::<your-s3-bucket-arn>",
                   "arn:aws:s3:::<your-s3-bucket-arn>/*"
               ]
           }
       ]
   }
   ```
3. **Save** your changes.

{% hint style="warning" %}
**Example policy**

The example policy may block bucket access for other services, which then need to be configured via separate statements. Configure bucket policies with caution.
{% endhint %}

### 3 - Configure the access summary export to S3

1. [Generate an Immuta API key](/saas/developer-guides/api-intro/authentication.md) on your profile page.
2. Make the following API call to the Immuta API:

```shellscript
curl 'https://<your.immuta.url>/access-summary/export-config' \
  -X POST \
  -H 'Authorization: Bearer <your API key>' \
  -H 'Content-type: application/json' \
  --data-raw '{"bucket": "<bucket name>","region": "<region>","accessKeyId":"<REDACTED>","secretAccessKey":"<REDACTED>","path": "<path>"}'
```

* **your Immuta URL**: The URL of your Immuta Govern app.
* **bucket name**: Name of the bucket your access summary will be sent to that you added the policy to above.
* **region**: AWS region (such as "us-east-1").
* **accessKeyId**: AWS access key ID for authentication. See the [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html#Using_CreateAccessKey) for information about using an access key ID and secret access key.
* **secretAccessKey**: AWS secret access key for authentication.
* **path**: The name of the folder within the bucket to put the access summary in. This field is optional.

### 4 - Verify the export configuration connection

If the configuration is successful, you will see the access summary export at 3AM local time.

## How to export using an AWS IAM role

Configure your Immuta access summary to export to your S3 bucket and allow Immuta to authenticate using an [AWS role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html). With this option, you provide Immuta with an IAM role from your AWS account that is granted a trust relationship with Immuta’s IAM role for adding objects to your S3 bucket. Immuta will assume this IAM role from Immuta’s AWS account in order to perform operations in your AWS account. Here's a visual representation of the authentication flow:

<figure><img src="/files/a0i7F3qL1jd1guqbhipp" alt=""><figcaption></figcaption></figure>

Immuta requires a role with the following allowed action to the S3 bucket you want the access summary exported to:

* [s3:PutObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html) which allows the role to add an object to a bucket.
* s3:ListBucket: Allows Immuta to use [ListObjectsV2](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html).

If your S3 bucket is encrypted, the following permissions must also be granted to the role:

* [kms:Decrypt](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html#aws-managed-customer-managed-keys): Allows Immuta to verify the integrity of the new data key before using it.
* [kms:GenerateDataKey](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html#aws-managed-customer-managed-keys): Allows Immuta to generate a key that is used to encrypt the objects that are exported to S3 using your KMS key.

### 1 - Configure an IAM role and policy

1. Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create.html) to create a new role for Immuta to assume and add objects to your S3 bucket.
2. Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html) for creating IAM policies in the Amazon S3 console for the new role.

   Here is an example IAM Policy that contains the required permissions for a KMS encrypted bucket. **If you are not using KMS encryption, you may omit the second statement**. If you use this example, replace the **content in angle brackets** with the [**Amazon Resource Names (ARNs)**](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) for your **S3 bucket** and **KMS key**:

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:ListBucket"
            ],
            "Resource": "<your-s3-bucket-arn>/*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "kms:Decrypt",
                "kms:GenerateDataKey"
            ],
            "Resource": "<your-kms-key-arn>"
        }
    ]
}
```

3. Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_update-role-permissions.html#id_roles_update-role-permissions-policy) to attach the policy to your newly created role.

### 2 - Create an S3 bucket policy for the export

Before Immuta can export the access summary to your S3 bucket using your configured IAM role, you need to create a bucket policy that allows that IAM role to add objects to your specified S3 bucket. The following Amazon S3 action must be granted in the bucket policy:

* [s3:PutObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html): Allows Immuta to upload objects to the bucket.

To create the policy for the bucket, you must be the bucket owner.

1. Follow [AWS documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html) for adding a bucket policy in the Amazon S3 console.
2. Edit the JSON in the **Policy** section to include a bucket policy like the example below.

   In this example, the policy allows an IAM user (the [principal](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-bucket-user-policy-specifying-principal-intro.html)) to add objects to the bucket.

   If you use this example, replace the **content in angle brackets** with the [**Amazon Resource Names (ARNs)**](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) for your **IAM role** and **S3 bucket**.

   ```json
   {
       "Version": "2012-10-17",
       "Statement": [
           {
               "Effect": "Allow",
               "Principal": {
                   "AWS": "<your-iam-role-arn>"
               },
               "Action": "s3:PutObject",
               "Resource": [
                   "arn:aws:s3:::<your-s3-bucket-arn>",
                   "arn:aws:s3:::<your-s3-bucket-arn>/*"
               ]
           }
       ]
   }
   ```
3. **Save** your changes.

{% hint style="warning" %}
**Example policy**

The example policy may block bucket access for other services, which then need to be configured via separate statements. Configure bucket policies with caution.
{% endhint %}

### 3 - Create a trust relationship and assume role policy

Follow [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html) for creating IAM trust relationships and assume role polices in the Amazon IAM console. Use the example JSON below to create a trust policy between Immuta and your AWS bucket.

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::475806706894:root"
            },
            "Action": "sts:AssumeRole",
            "Condition": {"StringEquals": {"sts:ExternalId": "<tenant ID>"}}
        }
    ]
}
```

**External ID**: Use your `<tenant ID>` as the external ID.

To retrieve your tenant ID:

1. Navigate to this URL: `https://[your.immuta.url]/deployment/tenant`
2. Use the `id` value from the response. That is your tenant ID.

For example:

```
"Condition": {"StringEquals": {"sts:ExternalId": "a9b28d9e-8e09-4735-bdb1-2f44ddbd4801"}}
```

### 4 - Configure the access summary export to S3

1. [Generate an Immuta API key](/saas/developer-guides/api-intro/authentication.md) on your profile page.
2. Make the following API call to the Immuta API:

```shellscript
curl 'https://<your.immuta.url>/access-summary/export-config' \
  -X POST \
  -H 'Authorization: Bearer <your API key>' \
  -H 'Content-type: application/json' \
  --data-raw '{"bucket": "<bucket name>","region": "<region>","roleArn": "<IAM role>","path": "<path>"}'
```

* **your Immuta URL**: The URL of your Immuta Govern app.
* **bucket name**: Name of the bucket your access summary will be sent to that you added the policy to above.
* **region**: Your AWS region (such as "us-east-1").
* **roleArn**: AWS role ARN for authentication that you added the policies to above. Immuta will assume this role when exporting the access summary to S3.
* **path**: The name of the folder within the bucket to put the access summary in.

### 5 - Verify the export configuration connection

Now that the configuration and the trust relationship have been created, you will see the access summary export at 5 AM local time.


---

# Agent Instructions: 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:

```
GET https://documentation.immuta.com/saas/govern/detect-your-data/access-summary-export/set-up-access-summary-export.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
