

# Prerequisites for integrating with external catalogs

Before you integrate with an external catalog, set up the caller permissions and two IAM roles. You also create an AWS Secrets Manager secret for each source. This topic describes these prerequisites. For more information, see [Integrating with external catalogs](catalog-external-catalogs.md).

## Caller permissions
<a name="catalog-external-catalogs-prerequisites-permissions"></a>

The following table lists the permissions that you need to integrate with an external catalog.


| Action | Required permissions | 
| --- | --- | 
| Create a connection | `glue:CreateConnection` | 
| Register a connection with Lake Formation for federation | `lakeformation:RegisterResource` | 
| Grant Lake Formation permissions to a role | `lakeformation:GrantPermissions` | 
| Create or update a catalog and turn on sync | `glue:CreateCatalog` or `glue:UpdateCatalog`, and `iam:PassRole` on the discovery and asset cataloging role. This doesn't require `glue:CreateCrawler`. | 
| Read or delete a catalog | `glue:GetCatalog` or `glue:DeleteCatalog` | 

## IAM roles
<a name="catalog-external-catalogs-prerequisites-roles"></a>

An external catalog integration uses two IAM roles in your account. You set up a discovery and asset cataloging role for the managed crawler, and a query engine credential-vending role for AWS vended credentials.

### Discovery and asset cataloging role
<a name="catalog-external-catalogs-prerequisites-crawler-role"></a>

The managed crawler runs as the discovery and asset cataloging role. This is an IAM role in your account that trusts the AWS Glue service principal `glue.amazonaws.com`. You set this role in `SyncConfiguration.RoleArn` when you turn on sync, and you must have the `iam:PassRole` permission on it. This role is not registered with Lake Formation.

Add the `aws:SourceAccount` condition key to the trust policy so that AWS Glue assumes the role only for your account. In the following trust policy, replace `{{account-id}}` with your account ID.

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "glue.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "{{account-id}}"
                }
            }
        }
    ]
}
```

Grant this role the Lake Formation `DESCRIBE` permission on the federated catalog before you turn on sync. When you grant the permission, you identify the role as the data lake principal by its role ARN. For the steps to grant Lake Formation permissions, see [Granting and revoking permissions on Data Catalog resources](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html) in the *AWS Lake Formation Developer Guide*.

### Query engine credential-vending role
<a name="catalog-external-catalogs-prerequisites-credential-vending-role"></a>

When a connection uses AWS vended credentials, Lake Formation assumes the query engine credential-vending role to vend credentials to the query engine. You register the connection with Lake Formation for federation and specify this role as the role that Lake Formation uses, by setting `WithFederation` to `true` with the `register-resource` operation. You also need this role for Amazon Athena federated queries. This role is not used with source vended credentials.

When you register the connection and grant Lake Formation permissions, you identify the role as the data lake principal by its role ARN. For the steps to register the resource and grant Lake Formation permissions on the federated catalog, see [Granting and revoking permissions on Data Catalog resources](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-catalog-permissions.html) in the *AWS Lake Formation Developer Guide*.

### VPC connections
<a name="catalog-external-catalogs-prerequisites-vpc"></a>

The `ROLE_ARN` connection property applies only to connections that use a VPC. For more information about VPC connections, see [Adding an AWS Glue connection](console-connections.md).

## Secrets Manager secret
<a name="catalog-external-catalogs-prerequisites-secret"></a>

Create one AWS Secrets Manager secret for each source. The connection uses AWS Secrets Manager for the source credentials and stores only the ARN of the secret. Deleting a connection doesn't delete its secret.

Use the following secret contents for each authentication type.

Databricks OAuth and Snowflake OAuth  
Store the client secret. The connector adds the access token to the same secret and refreshes it. For Snowflake, the connector also adds the refresh token.  

```json
{
    "USER_MANAGED_CLIENT_APPLICATION_CLIENT_SECRET": "{{client-secret}}"
}
```

Snowflake key pair  
Store the Snowflake user name and the unencrypted PKCS\#8 private key.  

```json
{
    "sfUser": "{{snowflake-user}}",
    "pem_private_key": "-----BEGIN PRIVATE KEY-----\n{{private-key}}\n-----END PRIVATE KEY-----"
}
```

## Placeholders in the examples
<a name="catalog-external-catalogs-prerequisites-placeholders"></a>

Replace the following placeholders in the examples with your own values:

`{{account-id}}`  
Your 12-digit AWS account ID.

`{{region}}`  
The AWS Region code of the catalog, for example `aa-example-1`.

`{{catalog-name}}`  
The name of the federated catalog.

`{{connection-name}}`  
The name of the AWS Glue connection.

`{{crawler-name}}`  
The name of the managed crawler.