# Register an AWS Lake Formation Connection

{% hint style="info" %}
**Public preview**: This feature is available to all accounts.
{% endhint %}

## Requirements

* [Data lake is set up in AWS Lake Formation](https://docs.aws.amazon.com/lake-formation/latest/dg/initial-lf-config.html). The account in which this is set up is referred to as the **admin account**. This is the account that you will use to initially configure IAM and AWS Lake Formation permissions to give the Immuta service principal access to perform operations. The user in this account must be able to manage IAM permissions and Lake Formation permissions for all data in the Glue Data Catalog.
* No AWS Lake Formation connections configured in the same Immuta instance for the same Glue Data Catalog.
* The databases and tables you want Immuta to govern must be [configured in AWS to respect the AWS Lake Formation permissions](https://docs.aws.amazon.com/lake-formation/latest/dg/initial-lf-config.html#setup-change-cat-settings). Immuta cannot govern resources that use IAM access control or hybrid access mode. To ensure Immuta can govern your resources, verify that the default Data Catalog settings in AWS are **unchecked.** See the screenshot below and [AWS documentation](https://docs.aws.amazon.com/lake-formation/latest/dg/initial-lf-config.html#setup-change-cat-settings) for instructions on changing these settings:

<figure><img src="https://1751699907-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlWBda5Pt4s8apEhzXGl7%2Fuploads%2Fgit-blob-8e9b22eb1317611f8ad9e06b902d176b2c8016bc%2Fdata-catalog-settings.png?alt=media" alt="The Use only IAM access control for new databases option and the Use only IAM access control for new tables in new databases option in the Data Catalog Settings section in AWS are unchecked so that Immuta can govern resources."><figcaption><p>AWS Data Catalog settings must be unchecked for Immuta to govern access.</p></figcaption></figure>

* [**Enable** **AWS IAM Identity Center (IDC) (recommended)**](#user-content-fn-1)[^1]: [IDC](https://aws.amazon.com/iam/identity-center/) is the best approach for user provisioning because it treats users as users, not users as roles. Consequently, access controls are enforced for the querying user, nothing more. This approach eliminates over-provisioning and permits granular access control. Furthermore, IDC uses trusted identity propagation, meaning AWS propagates a user's identity wherever that user may operate within the AWS ecosystem. As a result, a user's identity always remains known and consistent as they navigate across AWS services, which is a key requirement for organizations to properly govern that user.

  Enabling IDC does not impact any existing access controls; it is additive. See the [map users section](#map-users) for instructions on mapping users from AWS IDC to user accounts in Immuta.

## Permissions

These are permissions that the user registering the connection must have in order to successfully complete setup.

* `APPLICATION_ADMIN` Immuta permission to register the connection
* [`Create LF-Tag` AWS permission](#user-content-fn-2)[^2]
* `DESCRIBE` AWS permission. You must have the `DESCRIBE` permission on the [required resources](https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html) in AWS:
  * All databases that should be registered in the connection
  * All tables that should be registered in the connection
  * Any LF-Tags you are using on the resources that should be registered in the connection
* The AWS account credentials or [AWS IAM role](#user-content-fn-3)[^3] you provide for the [Immuta service principal](#set-up-the-immuta-service-principal) must have permissions to perform the following actions to register data and apply policies:
  * [Glue Data Catalog actions](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsglue.html)
    * `glue:GetDatabase`
    * `glue:GetTables`
    * `glue:GetDatabases`
    * `glue:GetTable`
  * [Lake Formation actions](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awslakeformation.html)
    * `lakeformation:ListPermissions`
    * `lakeformation:BatchGrantPermissions`
    * `lakeformation:BatchRevokePermissions`
    * `lakeformation:CreateLFTag`
    * `lakeformation:UpdateLFTag`
    * `lakeformation:DeleteLFTag`
    * `lakeformation:AddLFTagsToResource`
    * `lakeformation:RemoveLFTagsFromResource`
    * `lakeformation:GetResourceLFTags`
    * `lakeformation:ListLFTags`
    * `lakeformation:GetLFTag`
    * `lakeformation:SearchTablesByLFTags`
    * `lakeformation:SearchDatabasesByLFTags`
  * `DESCRIBE` Lake Formation permission on any LF-Tags you want to have pulled into Immuta and applied to data sources through tag ingestion

## Set up the Immuta service principal

The Immuta service principal is the [AWS IAM role that Immuta will assume](#user-content-fn-4)[^4] to perform operations in your AWS account. This role must have all the necessary permissions in AWS Glue and AWS Lake Formation to allow Immuta to register data sources and apply policies.

1. Create an IAM policy with the following AWS Lake Formation and AWS Glue permissions. You will attach this to your service principal once created.

```
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "glue:GetDatabase",
        "glue:GetTables",
        "glue:GetDatabases",
        "glue:GetTable",
        "lakeformation:ListPermissions",
        "lakeformation:BatchGrantPermissions",
        "lakeformation:BatchRevokePermissions",
        "lakeformation:CreateLFTag",
        "lakeformation:UpdateLFTag",
        "lakeformation:DeleteLFTag",
        "lakeformation:AddLFTagsToResource",
        "lakeformation:RemoveLFTagsFromResource",
        "lakeformation:GetResourceLFTags",
        "lakeformation:ListLFTags",
        "lakeformation:GetLFTag",
        "lakeformation:SearchTablesByLFTags",
        "lakeformation:SearchDatabasesByLFTags"
      ],
      "Resource": "*"
    }
  ]
}
```

2. [Create an IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user.html) and select **AWS Account** as the trusted entity type. This role will be used by Immuta to set up the connection and orchestrate AWS Lake Formation policies. Immuta will assume this IAM role from Immuta's AWS account in order to perform any operations in your AWS account.
3. Add the IAM policy from step 1 to your service principal. These permissions will allow the service principal to register data sources and apply policies on Immuta's behalf.
4. Add the service principal as an [LF-Tag Creator](https://docs.aws.amazon.com/lake-formation/latest/dg/TBAC-adding-tag-creator.html#add-lf-tag-creator).
   1. In the Lake Formation console, navigate to **Permissions**.
   2. Select **LF-Tags and permissions**.
   3. Select **LF-Tag creators**, and then **Add LF-Tag creators**.
   4. Enter your service principal, and grant it the **Create LF-Tag** permission and grantable permission.
   5. Click **Add** to save your changes.
5. Grant the service principal permissions on any tables that will be registered in Immuta. There are two ways to give the service principal these permissions: either make a new LF-Tag that gives the appropriate permissions and apply it to [all databases or tables that Immuta will manage](#user-content-fn-5)[^5], or make the role a superuser in Lake Formation.

{% tabs %}
{% tab title="LF-Tag permissions (recommended)" %}
This method follows the principle of least privilege and is the most flexible way of granting permissions to the service principal. LF-Tags cascade down from databases to tables, while allowing for exceptions. This means that when you apply this tag to a database, it will automatically apply to all tables within that database and allow you to remove it from any tables if those should be out of the scope of Immuta’s governance.

1. Create a new LF-Tag, giving yourself permissions to grant that tag to a user, which will ultimately be your service principal.
   1. In the Lake Formation console, navigate to **LF-Tags and permissions** and click **Add LF-Tag**. You will need the `Create LF-Tag` permission to do this.
   2. Create a single **tag key with one tag value**. For example,
      1. Tag key: `immuta_governed`
      2. Tag value: `true`
   3. On the **LF-Tag key-value pair**, grant the `ASSOCIATE` LF-Tag permission to *your own IAM principal*.
2. Grant this tag to the Immuta service principal.
   1. In the Lake Formation console, navigate to **Data permissions** and click **Grant**.
   2. Enter the **service principal’s IAM role**.
   3. Add the **key-value pair** of the tag you created in step 1.
   4. Under **Table Permissions**, select the following grantable permissions: `SELECT`, `DESCRIBE`, `INSERT`, `DELETE`.
   5. Click **Grant**.
3. [Apply this **tag** to the **resources** you would like Immuta to govern.](https://docs.aws.amazon.com/lake-formation/latest/dg/TBAC-assigning-tags.html) The Immuta service principal will now have the minimum required permissions on these resources. If new resources are created in AWS, you must repeat this process of applying this tag to those resources if you want Immuta to govern them.
   {% endtab %}

{% tab title="Superuser" %}
{% hint style="warning" %}
This option enables all Lake Formation operations on all data in the Glue Data Catalog. This is highly privileged and runs the risk of managing permissions on data you did not intend to.
{% endhint %}

This method will grant all necessary permissions to the service principal, but grants more than the service principal needs without being as flexible, since it does not allow for exceptions like the LF-Tag method. You can make the service principal a superuser on the entire catalog or specify individual resources.

1. In the Lake Formation console, navigate to **Data permissions** and click **Grant**.
2. Enter your **service principal’s IAM role**.
3. Select **Named Data Catalog resources**, and input the **Glue Data Catalog ID** and any **databases** or **tables** you wish to specify.
4. Under **Grantable permissions**, select **Super** and click **Grant**.

Follow the [AWS documentation](https://docs.aws.amazon.com/lake-formation/latest/dg/change-settings.html) to grant `ALL` permissions to the `DataLakePrincipalIdentifier` for the Immuta service principal ARN.
{% endtab %}
{% endtabs %}

## Register an AWS Lake Formation connection

1. Click <i class="fa-database">:database:</i> **Data** and select **Connections** in the navigation menu.
2. Click the **+ Add Connection** button.
3. Select the **AWS Lake Formation** tile.
4. Enter the host connection information:
   1. **Display Name:** This is the name of your new connection. This name will be used in the API (`connectionKey`), in data source names from the host, and on the connections page. Avoid the use of periods (`.`) or [restricted words](#user-content-fn-6)[^6] in your connection name.
   2. **AWS Account ID:** The ID of the AWS account associated with the Glue Data Catalog.
   3. **AWS Region:** The region of the AWS account associated with the Glue Data Catalog.
   4. Opt to enable Immuta to **Ingest Lake Formation Tags** (private preview): This will ensure your Lake Formation Tags are applied to your data sources in Immuta.
5. Click **Next**.
6. Select an authentication method from the dropdown menu.
   1. **AWS Access Key and Secret Access Key:** Provide the access key ID and secret access key for an AWS account with the [AWS permissions listed in the set up the Immuta service principal section](#set-up-the-immuta-service-principal).
   2. **AWS IAM Role** (recommended): Immuta will assume this IAM role from Immuta's AWS account in order to perform any operations in your AWS account.
      1. Enter your service principal's role ARN in the **AWS IAM Role** field. Immuta will assume this role when interacting with AWS.
      2. Copy the trust policy displayed below the AWS IAM Role field. You will paste this in your service principal's trust policy in the next step.
      3. In AWS, navigate to your service principal's **Trust Relationships tab** and edit the existing trust relationship. Paste the trust policy you copied from the Immuta UI and save your changes.
7. In Immuta, ensure that you have the correct permissions and click **Validate Connection**.
8. If the connection is successful, click **Next**. If there are any errors, check the connection details and credentials to ensure they are correct and try again.
9. Ensure all the details are correct in the summary and click **Complete Setup**.

## Map users

**Requirement**: `USER_ADMIN` Immuta permission

Map AWS IAM principals to each Immuta user to ensure Immuta properly enforces policies.

1. Click **People** and select **Users** in the navigation menu.
2. Click the user's **name** to navigate to their page and scroll to the **External User Mapping** section.
3. Click **Edit** in the **AWS User** row.
4. Use the dropdown menu to select the **User Type**. User and role names are case-sensitive. See the [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html) for details.
   * [**AWS IAM role**](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-roles): Only a single Immuta user can be mapped to an IAM role. This restriction prohibits enforcing policies on AWS users who could assume that role. Therefore, if using role principals, create a new user in Immuta that represents the role so that the role then has the permissions applied specifically to it.
   * [**AWS IAM user**](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-users)
   * **AWS Identity Center user IDs**: You must use the numeric `User ID` value found in AWS IAM Identity Center, not the user's email address.
   * **Unset (fallback to Immuta username)**: When selecting this option, the AWS username is assumed to be the same as the Immuta username.
5. Click **Save**.

See the [Mapping IAM principals in Immuta section](https://documentation.immuta.com/SaaS/configuration/integrations/reference-guides/aws-lake-formation#mapping-iam-principals-in-immuta) for details about supported principals.

[^1]: See the [User provisioning](https://documentation.immuta.com/SaaS/configuration/integrations/reference-guides/aws-lake-formation#user-provisioning) section for more details about this recommendation and alternatives.

[^2]: This permission is only required if using the [LF-Tag permissions method](#lf-tag-permissions-recommended) to set up the Immuta service principal.

[^3]: Instructions for setting up this role and granting the necessary permissions are provided in the [set up the Immuta service principal section](#set-up-the-immuta-service-principal).

[^4]: The Immuta service principal can also be an IAM user authenticating with an access key and secret key. However, this option is not recommended.

[^5]: You can opt to apply the LF-Tag to just the database, as this will also tag all the tables within the database.

[^6]: Your display name cannot be any of the following words: `data`, `connection`, `object`, `crawl`, `search`, `settings`, `metadata`, `permission`, `sync`, `bulk`, and `upgrade`.
