# Configuring S3 Bucket for Redshift Imports

If you navigate to **Settings > Advanced Settings > Integrations**, you'll find a setting related to configuring your own S3 bucket to import files into Redshift.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-bdf7a6daf3a21434022f30e9a93e77066a8c46e3%2FScreenshot%202023-03-09%20at%2013.12.22.png?alt=media" alt=""><figcaption></figcaption></figure>

## When is this needed?

To import geospatial files seamlessly into your own Amazon Redshift data warehouse, CARTO needs to use an S3 bucket as a middle step, as required by Redshift.

{% hint style="info" %}
In **CARTO Cloud** organizations this setting is optional because we provide a pre-configured S3 bucket at all times.

* The import feature will always be enabled for Redshift
* You can use this setting to customize and force the imports to use your own S3 Bucket
  {% endhint %}

{% hint style="warning" %}
In **CARTO Self-Hosted** organizations you need to configure this setting to be able to import geospatial files into Redshift using CARTO.
{% endhint %}

Remember that to configure this setting, you previously need to create an S3 bucket in AWS. We recommend you use a fresh new bucket exclusively for this purpose.

## Setting up your S3 bucket

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-c7de3099cdd66b051ac70ce12491d7c2a74d5e3e%2FScreenshot%202023-03-09%20at%2013.14.14.png?alt=media" alt=""><figcaption></figcaption></figure>

First, click on "+ Add" to begin the process. Once inside, tell us the **Bucket name** and the **Region** of the S3 Bucket you want to use when importing files.

{% hint style="warning" %}
This S3 bucket needs to be **located in the same region as your Amazon Redshift cluster**.
{% endhint %}

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-4a895334893256df909269fb534201a041fe2826%2FScreenshot%202023-03-09%20at%2013.15.36.png?alt=media" alt=""><figcaption></figcaption></figure>

Once you've added the name and region, click on **Generate policy.** This will generate a policy in the code block on the left side, and you should be able to copy it.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-88239fafbf1c578cc74a6adf9bfc11e185d820be%2FScreenshot%202023-03-09%20at%2013.19.43.png?alt=media" alt=""><figcaption></figcaption></figure>

## Adding the bucket policy in AWS

{% hint style="info" %}
This step is done in the AWS console. You'll need admin access to the bucket configuration. If you don't have it, just forward an admin these instructions.

[The official documentation from AWS](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html) covers how to add policies and modify other settings mentioned here.
{% endhint %}

1. Copy and **paste the policy** generated by CARTO into the policies of your S3 Bucket in AWS.
2. Make sure **ACLs are allowed**. This is a must for CARTO to use your S3 bucket.
3. Your S3 Bucket can use **encryption** but it needs to be managed by AWS.
4. Additionally, you must add a **Cross-origin resource sharing (CORS)** policy (under the Permissions tab), like the one below. Please replace `*.app.carto.com` by your specific tenant domain in Self-Hosted deployments.

{% code overflow="wrap" %}

```
[ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "PUT" ], "AllowedOrigins": [ "https://*.app.carto.com" ], "ExposeHeaders": [ "ETag" ], "MaxAgeSeconds": 0 } ]
```

{% endcode %}

## Validate and save

Once you've finished the configuration in AWS, go back to CARTO. Mark the *"I have already added the S3 bucket policy"* checkbox as done and click on "**Validate and Save**"

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2Fgit-blob-0bb4afa7d3ca9cafd2acd2d050120792f480b0a3%2FScreenshot%202023-03-09%20at%2013.27.29.png?alt=media" alt=""><figcaption></figcaption></figure>

CARTO will validate your configuration at this point. If we're able to use your S3 bucket to import files into Redshift, we'll take you back to your Settings page.

{% hint style="success" %}
From this point, CARTO will always use your S3 bucket when importing, and the import feature will be enabled if it wasn't before
{% endhint %}

You can edit or remove this integration at any time.
