# Configure an Amazon Redshift Spectrum Integration

```mermaid
graph LR
A(Authenticate) --> B(Configure integration) --> C(Map users and create policies) --> D(Register metadata);
style A fill:#fff
style B fill:#2F6BA7,color:#fff
style C fill:#fff
style D fill:#fff
```

In the Amazon Redshift Spectrum integration, Immuta generates policy-enforced views in your configured Redshift schema for tables registered as Immuta data sources.

Use the `/integrations` endpoint to

* [configure an Amazon Redshift Spectrum integration](#configure-the-integration)
* [get an Amazon Redshift Spectrum integration](#get-an-integration)
* [get all integrations](#get-all-integrations)
* [update an Amazon Redshift Spectrum integration](#update-an-integration-configuration)
* [delete an Amazon Redshift Spectrum integration](#delete-an-integration)

## Requirements

* A Redshift cluster with an AWS row-level security patch applied. [Contact Immuta](https://support.immuta.com/) for guidance.
* [An AWS IAM role for Redshift](https://docs.aws.amazon.com/redshift/latest/dg/c-getting-started-using-spectrum-create-role.html) that is [associated with your Redshift cluster](https://docs.aws.amazon.com/redshift/latest/dg/c-getting-started-using-spectrum-add-role.html).
* The [`enable_case_sensitive_identifier` parameter](https://docs.aws.amazon.com/redshift/latest/dg/r_enable_case_sensitive_identifier.html) must be set to `false` (default setting) for your Redshift cluster.
* [A Redshift database that contains an external schema and external tables](https://docs.aws.amazon.com/redshift/latest/dg/c-getting-started-using-spectrum-create-external-table.html).

## Permissions

The user configuring the integration must have the permissions below.

* `APPLICATION_ADMIN` Immuta permission
* The Redshift role used to run the Immuta bootstrap script must have the following privileges when configuring the integration:
  * If using an existing database
    * `ALL PRIVILEGES ON DATABASE` for the database you configure the integration with, as you must manage grants on that database.
    * `CREATE USER`
    * `GRANT TEMP ON DATABASE`
  * If creating a new database
    * `CREATE DATABASE`
    * `CREATE USER`
    * `GRANT TEMP ON DATABASE`
    * `REVOKE ALL PRIVILEGES ON DATABASE`

## Configure the integration

To configure the integration, complete the following steps:

1. [Set up an Immuta database in Amazon Redshift](#setup-the-immuta-database).
2. [Generate the Immuta script and run it inside the database you created.](#generate-the-script)
3. [Configure the integration in Immuta.](#configure-the-integration-in-immuta)

### Setup the Immuta database

You have two options for setting up the database Immuta will use to manage the integration and enforce policies:

* **Configure the integration with an existing database that contains the external tables**. When configuring the integration, specify an existing database in Amazon Redshift as the `database` in which Immuta will add the Immuta-managed schemas and views.

  \
  If using an existing database, the Redshift role used to run the Immuta bootstrap script must have the following privileges:

  * `ALL PRIVILEGES ON DATABASE` for the database you configure the integration with, as you must manage grants on that database.
  * `CREATE USER`
  * `GRANT TEMP ON DATABASE`
* **Create a new database**: Create a new database for Immuta that manages all schemas and views created when Redshift data is registered in Immuta, and re-create all of your external tables in that database.\
  \
  When configuring the integration, specify this new database you created in Amazon Redshift as the `database` in which Immuta will add the Immuta-managed schemas and views.\
  \
  If creating a new database, the Redshift role used to run the Immuta bootstrap script must have the following privileges:
  * `CREATE DATABASE`
  * `CREATE USER`
  * `GRANT TEMP ON DATABASE`
  * `REVOKE ALL PRIVILEGES ON DATABASE`

### Generate the script

```bash
curl -X 'POST' \
    'https://www.organization.immuta.com/integrations/scripts/create' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: 846e9e43c86a4ct1be14290d95127d13f' \
    -d '{
    "type": "Redshift",
    "autoBootstrap": false,
    "config": {
      "host": "organization.aws.amazon.com",
      "database": "immuta",
      "impersonation": {
        "enabled": false
      },
      "authenticationType": "userPassword",
      "username": "taylor@redshift.com",
      "password": "abc1234"
    }
    }'
```

1. Copy the request example. The example provided uses JSON format, but the request also accepts YAML.
2. Replace the **Immuta URL** and [**API key**](/saas/developer-guides/api-intro/integrations-api/getting-started.md#authenticate-with-the-api) with your own.
3. Change the **config** values to your own, where
   * **host** is the URL of your Redshift account.
   * **database** is the name of the [existing or new database](#setup-the-immuta-database) that the Immuta system user will manage and store metadata in.
   * **impersonation** specifies whether user impersonation is enabled. See the [object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-impersonation-object) for child parameters. Once you finish configuring the integration, you can grant the `IMPERSONATE_USER` permission to Immuta users. See the [Managing users and permissions guide](/saas/configuration/people/users-index/how-to-guides/managing-personas-and-permissions.md#add-permission-to-user) for instructions.
   * **username** and **password** are the credentials for the system account that can act on Redshift objects and configure the integration.
4. Run the script returned in the response in the existing or new database you created in Amazon Redshift.

See the [**config** object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-configuration-objects) for parameter definitions, value types, and additional configuration options.

**Response**

The response returns the script for you to run in the existing or new database you created for the Immuta system user.

### Configure the integration in Immuta

```bash
curl -X 'POST' \
    'https://www.organization.immuta.com/integrations' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: 846e9e43c86a4ct1be14290d95127d13f' \
    -d '{
    "type": "Redshift",
    "autoBootstrap": false,
    "config": {
      "host": "organization.aws.amazon.com",
      "database": "immuta",
      "impersonation": {
        "enabled": false
      },
      "authenticationType": "userPassword",
      "username": "taylor@redshift.com",
      "password": "abc1234"
    }
    }'
```

1. Copy the request example. The example provided uses JSON format, but the request also accepts YAML.
2. Replace the **Immuta URL** and [**API key**](/saas/developer-guides/api-intro/integrations-api/getting-started.md#authenticate-with-the-api) with your own.
3. Pass the same payload you sent when [generating the script](#generate-the-first-script), where
   * **host** is the URL of your Redshift account.
   * **database** is the name of the [existing or new database](#setup-the-immuta-database) that the Immuta system user will manage and store metadata in.
   * **impersonation** specifies whether user impersonation is enabled. See the [object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-impersonation-object) for child parameters. Once you finish configuring the integration, you can grant the `IMPERSONATE_USER` permission to Immuta users. See the [Managing users and permissions guide](/saas/configuration/people/users-index/how-to-guides/managing-personas-and-permissions.md#add-permission-to-user) for instructions.
   * **username** and **password** are the credentials for the system account that can act on Redshift objects and configure the integration.

See the [**config** object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-configuration-objects) for parameter definitions, value types, and additional configuration options.

#### Response

The response returns the status of the Amazon Redshift Spectrum integration configuration connection. See the [response schema reference](/saas/developer-guides/api-intro/integrations-api/reference-guides/response-schema.md) for details about the response schema.

{% tabs %}
{% tab title="200 response" %}
A successful response includes the validation tests statuses.

```json
{
  "id": "123456789",
  "status": "creating",
  "validationResults": {
    "status": "passed",
    "validationTests": [
    {
      "name": "Initial Validation: Basic Connection Test",
      "result": [null],
      "status": "passed"
    },
    {
      "name": "Validate Automatic: Immuta Database Does Not Exist",
      "result": [],
      "status": "passed"
    }
    ]
  }
}
```

{% endtab %}

{% tab title="Unsuccessful response" %}
An unsuccessful request returns the status code and an error message. See the [HTTP status codes and error messages](/saas/developer-guides/api-intro/integrations-api/reference-guides/status-codes.md#post-errors) for a list of statuses, error messages, and troubleshooting guidance.

```json
{
  "statusCode": 409,
  "error": "Conflict",
  "message": "Redshift integration already exists on host organization.aws.amazon.com (id = 123456789)"
}
```

{% endtab %}
{% endtabs %}

## Get an integration

```bash
curl -X 'GET' \
    'https://www.organization.immuta.com/integrations/{id}' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: 846e9e43c86a4ct1be14290d95127d13f'
```

1. Copy the request example.
2. Replace the **Immuta URL** and [**API key**](/saas/developer-guides/api-intro/integrations-api/getting-started.md#authenticate-with-the-api) with your own.
3. Replace the **{id}** request parameter with the unique identifier of the integration you want to get. Alternatively, you can get a list of all integrations and their IDs with the [<mark style="color:blue;">`GET /integrations`</mark> <mark style="color:blue;">endpoint</mark>](/saas/developer-guides/api-intro/integrations-api/reference-guides/integrations-api.md#get-integrations).

### Response

The response returns an Amazon Redshift Spectrum integration configuration. See the [response schema reference](/saas/developer-guides/api-intro/integrations-api/reference-guides/response-schema.md) for details about the response schema. An unsuccessful request returns the status code and an error message. See the [HTTP status codes and error messages](/saas/developer-guides/api-intro/integrations-api/reference-guides/status-codes.md#get-error) for a list of statuses, error messages, and troubleshooting guidance.

```json
{
  "id": "123456789",
  "status": "enabled",
  "validationResults": {
    "status": "passed",
    "validationTests": [
    {
      "name": "Initial Validation: Basic Connection Test",
      "result": [null],
      "status": "passed"
    },
    {
      "name": "Validate Automatic: Immuta Database Does Not Exist",
      "result": [],
      "status": "passed"
    }
    ]
  },
  "type": "Redshift",
  "autoBootstrap": false,
  "config": {
    "host": "organization.aws.amazon.com",
    "database": "immuta",
    "port": 5439,
    "impersonation": {
      "enabled": false
    },
    "authenticationType": "userPassword",
    "username": "<REDACTED>",
    "password": "<REDACTED>"
  }
}
```

## Get all integrations

```bash
curl -X 'GET' \
    'https://www.organization.immuta.com/integrations' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: 846e9e43c86a4ct1be14290d95127d13f'
```

1. Copy the request example.
2. Replace the **Immuta URL** and [**API key**](/saas/developer-guides/api-intro/integrations-api/getting-started.md#authenticate-with-the-api) with your own.

### Response

The response returns the configuration for all integrations. See the [response schema reference](/saas/developer-guides/api-intro/integrations-api/reference-guides/response-schema.md) for details about the response schema. An unsuccessful request returns the status code and an error message. See the [HTTP status codes and error messages](/saas/developer-guides/api-intro/integrations-api/reference-guides/status-codes.md#get-error) for a list of statuses, error messages, and troubleshooting guidance.

```json
[
  {
    "id": "1",
    "status": "enabled",
    "validationResults": {
      "status": "passed",
      "validationTests": [
        {
          "name": "Initial Validation: Basic Connection Test",
          "status": "passed"
        },
        {
          "name": "Initial Validation: Default Warehouse Access Test",
          "status": "passed",
          "result": []
        },
        {
          "name": "Initial Validation: Validate access to Privileged Role",
          "status": "passed",
          "result": []
        },
        {
          "name": "Validate Automatic: Database Does Not Exist",
          "status": "passed"
        },
        {
          "name": "Validate Automatic: Impersonation Role Does Not Exist",
          "status": "skipped"
        },
        {
          "name": "Validate Automatic: User Grants",
          "status": "passed"
        }
      ]
    },
    "type": "Snowflake",
    "autoBootstrap": true,
    "config": {
      "host": "organization.us-east-1.snowflakecomputing.com",
      "warehouse": "SAMPLE_WAREHOUSE",
      "database": "SNOWFLAKE_SAMPLE_DATA",
      "port": 443,
      "audit": {
        "enabled": false
      },
      "workspaces": {
        "enabled": false
      },
      "impersonation": {
        "enabled": false
      },
      "lineage": {
        "enabled": false
      },
      "authenticationType": "userPassword",
      "username": "<REDACTED>",
      "password": "<REDACTED>",
      "role": "ACCOUNTADMIN"
    }
  },
  {
    "id": "2",
    "status": "enabled",
    "type": "Databricks",
    "validationResults": {
      "status": "passed",
      "validationTests": [
        {
          "name": "Metastore validation",
          "status": "passed"
        },
        {
          "name": "Basic Connection Test",
          "result": [
            {
              "1": 1
            }
          ],
          "status": "passed"
        }
      ]
    },
    "autoBootstrap": true,
    "config": {
      "workspaceUrl": "www.example-workspace.cloud.databricks.com",
      "httpPath": "sql/protocolv1/o/0/0000-00000-abc123",
      "token": "REDACTED",
      "audit": {
        "enabled": false
      },
      "catalog": "immuta"
    }
  }
]
```

## Update an integration configuration

To update the integration, complete the following steps:

1. [Generate the updated Immuta script and run it in your Redshift environment.](#generate-the-updated-script)
2. [Update the integration in Immuta.](#update-the-integration-in-immuta)

### Generate the updated script

```bash
curl -X 'POST' \
    'https://www.organization.immuta.com/integrations/{id}/scripts/edit' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: 846e9e43c86a4ct1be14290d95127d13f' \
    -d '{
    "type": "Redshift",
    "autoBootstrap": false,
    "config": {
      "host": "organization.aws.amazon.com",
      "database": "immuta",
      "impersonation": {
        "enabled": false
      },
      "authenticationType": "userPassword",
      "username": "taylor@redshift.com",
      "password": "abc1234"
    }
    }'
```

1. Copy the request example. The example provided uses JSON format, but the request also accepts YAML.
2. Replace the **Immuta URL** and [**API key**](/saas/developer-guides/api-intro/integrations-api/getting-started.md#authenticate-with-the-api) with your own.
3. Replace the **{id}** request parameter with the unique identifier of the integration you want to update.
4. Change the **config** values to your own, where
   * **host** is the URL of your Redshift account.
   * **database** is the name of the [existing or new database](#setup-the-immuta-database) that the Immuta system user will manage and store metadata in.
   * **impersonation** specifies whether user impersonation is enabled. See the [object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-impersonation-object) for child parameters. Once you finish configuring the integration, you can grant the `IMPERSONATE_USER` permission to Immuta users. See the [Managing users and permissions guide](/saas/configuration/people/users-index/how-to-guides/managing-personas-and-permissions.md#add-permission-to-user) for instructions.
   * **username** and **password** are the credentials for the system account that can act on Redshift objects and configure the integration.
5. Run the script returned in the response in your Amazon Redshift environment.

See the [**config** object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-configuration-objects) for parameter definitions, value types, and additional configuration options.

**Response**

The response returns the script for you to run in your Amazon Redshift environment.

### Update the integration in Immuta

```bash
curl -X 'PUT' \
    'https://www.organization.immuta.com/integrations/{id}' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: 846e9e43c86a4ct1be14290d95127d13f' \
    -d '{
    "type": "Redshift",
    "autoBootstrap": false,
    "config": {
      "host": "organization.aws.amazon.com",
      "database": "immuta",
      "impersonation": {
        "enabled": false
      },
      "authenticationType": "userPassword",
      "username": "taylor@redshift.com",
      "password": "abc1234"
    }
    }'
```

1. Copy the request example. The example provided uses JSON format, but the request also accepts YAML.
2. Replace the **Immuta URL** and [**API key**](/saas/developer-guides/api-intro/integrations-api/getting-started.md#authenticate-with-the-api) with your own.
3. Replace the **{id}** request parameter with the unique identifier of the integration you want to update.
4. Pass the same payload you sent when [updating the script](#generate-the-updated-script), where
   * **host** is the URL of your Redshift account.
   * **database** is the name of the [existing or new database](#setup-the-immuta-database) that the Immuta system user will manage and store metadata in.
   * **impersonation** specifies whether user impersonation is enabled. See the [object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-impersonation-object) for child parameters. Once you finish configuring the integration, you can grant the `IMPERSONATE_USER` permission to Immuta users. See the [Managing users and permissions guide](/saas/configuration/people/users-index/how-to-guides/managing-personas-and-permissions.md#add-permission-to-user) for instructions.
   * **username** and **password** are the credentials for the system account that can act on Redshift objects and configure the integration.

See the [**config** object description](/saas/developer-guides/api-intro/integrations-api/reference-guides/integration-configuration-payload.md#redshift-spectrum-configuration-objects) for parameter definitions, value types, and additional configuration options.

#### Response

The response returns the status of the Amazon Redshift Spectrum integration configuration connection. See the [response schema reference](/saas/developer-guides/api-intro/integrations-api/reference-guides/response-schema.md) for details about the response schema.

{% tabs %}
{% tab title="200 response" %}
A successful response includes the validation tests statuses.

```json
{
  "id": "123456789",
  "status": "editing",
  "validationResults": {
    "status": "passed",
    "validationTests": [
    {
      "name": "Initial Validation: Basic Connection Test",
      "result": [null],
      "status": "passed"
    },
    {
      "name": "Validate Automatic: Immuta Database Does Not Exist",
      "result": [],
      "status": "passed"
    }
    ]
  }
}
```

{% endtab %}

{% tab title="Unsuccessful response" %}
An unsuccessful request returns the status code and an error message. See the [HTTP status codes and error messages](/saas/developer-guides/api-intro/integrations-api/reference-guides/status-codes.md#put-errors) for a list of statuses, error messages, and troubleshooting guidance.

```json
{
  "statusCode": 409,
  "error": "Conflict",
  "message": "Unable to edit integration with ID 123456789 in current state editing."
}
```

{% endtab %}
{% endtabs %}

## Delete an integration

```bash
curl -X 'DELETE' \
    'https://www.organization.immuta.com/integrations/{id}' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: 846e9e43c86a4ct1be14290d95127d13f'
```

1. Use the script [cleanup](/saas/developer-guides/api-intro/integrations-api/reference-guides/integrations-api.md#post-integrations-scripts-cleanup) endpoint (for integrations that were not successfully created) or the [delete](/saas/developer-guides/api-intro/integrations-api/reference-guides/integrations-api.md#post-integrations-id-scripts-delete) endpoint (for integrations that were successfully created) to remove Immuta-managed resources from your Amazon Redshift environment.
2. Copy the request example.
3. Replace the **Immuta URL** and [**API key**](/saas/developer-guides/api-intro/integrations-api/getting-started.md#authenticate-with-the-api) with your own.
4. Replace the **{id}** request parameter with the unique identifier of the integration you want to delete.

### Response

The response returns the status of the Amazon Redshift Spectrum integration configuration that has been deleted. See the [response schema reference](/saas/developer-guides/api-intro/integrations-api/reference-guides/response-schema.md) for details about the response schema. An unsuccessful request returns the status code and an error message. See the [HTTP status codes and error messages](/saas/developer-guides/api-intro/integrations-api/reference-guides/status-codes.md#delete-errors) for a list of statuses, error messages, and troubleshooting guidance.

```json
{
  "id": "123456789",
  "status": "deleting",
  "validationResults": {
    "status": "passed",
    "validationTests": [
    {
      "name": "Initial Validation: Basic Connection Test",
      "result": [null],
      "status": "passed"
    },
    {
      "name": "Validate Automatic: Immuta Database Does Not Exist",
      "result": [],
      "status": "passed"
    }
    ]
  }
}
```


---

# 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/developer-guides/api-intro/integrations-api/how-to-guides/configure-an-amazon-redshift-spectrum-integration.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.
