

# Setting up IAM policies for DataBrew


You use IAM policies to manage permissions. A policy makes it easier to add related permissions all at once, rather than one at a time. 

We recommend that you create the policies using the same names we provide. We use the names shown following for these policies throughout the documentation. Using these names also makes it easier if you ever need to contact AWS Support. However, you can choose to change both the policy names and their contents. For more information about IAM policies, see [Create a customer managed policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_managed-policies.html) in the *IAM User Guide*. 

After you create the policies needed to use DataBrew, you attach them to users and roles. How to do this is covered later in this section.

**Topics**
+ [

# Adding an IAM policy for a console user
](setting-up-iam-policy-for-databrew-console-access.md)
+ [

# Adding permissions for data resources for an IAM role
](setting-up-iam-policy-for-data-resources-role.md)
+ [

# Configuring IAM policies for DataBrew
](iam-policy-config-for-databrew.md)

# Adding an IAM policy for a console user
Adding an IAM policy for a console user

Setting up permissions for a user for the AWS Management Console is optional, but if you require console access, take this step first.

To set up permissions to reach DataBrew on the console, choose one of the following:
+ Use the policy that's managed by AWS: `AwsGlueDataBrewFullAccessPolicy`. If you choose this option, skip to the next policy, [Adding permissions for data resources for an IAM role](setting-up-iam-policy-for-data-resources-role.md). 
+ Create the policy described in this section, `AwsGlueDataBrewCustomUserPolicy`. This option enables you to customize the policy with additional custom security requirements.

The following policy grants the permissions needed to run the DataBrew console. You provide those permissions by using IAM.<a name="AwsGlueDataBrewCustomUserPolicy-console-steps"></a>

**To define the AwsGlueDataBrewCustomUserPolicy IAM policy for DataBrew (console)**

1. Download the JSON for the [samples/AwsGlueDataBrewCustomUserPolicy.json.zip](samples/AwsGlueDataBrewCustomUserPolicy.json.zip) IAM policy. 

1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/). 

1. In the navigation pane, choose **Policies**.

1. For each policy, choose **Create Policy**.

1. On the **Create Policy** screen, navigate to the **JSON** tab. 

1. Copy the policy JSON statement that you downloaded. Paste it over the sample statement in the editor.

1. Verify that the policy is customized to your account, security requirements, and required AWS resources. If you need to make changes, you can make them in the editor.

1. Choose **Review policy**.<a name="AwsGlueDataBrewCustomUserPolicy-cli-steps"></a>

**To define the AwsGlueDataBrewCustomUserPolicy IAM policy for DataBrew (AWS CLI)**

1. Download the JSON for the [samples/AwsGlueDataBrewCustomUserPolicy.json.zip](samples/AwsGlueDataBrewCustomUserPolicy.json.zip) IAM policy. 

1. Customize the policy as described in the first step of the previous procedure.

1. Run the following command to create the policy.

   ```
   aws iam create-policy --policy-name AwsGlueDataBrewCustomUserPolicy --policy-document file://iam-policy-AwsGlueDataBrewCustomUserPolicy.json
   ```

# Adding permissions for data resources for an IAM role
Adding permissions for DataBrew data resources

To connect to data, AWS Glue DataBrew needs to have an IAM role that it can pass on behalf of the user. Following, you can find how to create the policy that you later attach to an IAM role. 

The `AwsGlueDataBrewDataResourcePolicy` policy grants the permissions needed to connect to data using DataBrew. For any operation that accesses data in another AWS resource, such as accessing your objects in Amazon S3, DataBrew needs permission to access the resource on your behalf. <a name="AwsGlueDataBrewDataResourcePolicy-console-steps"></a>

**To define the AwsGlueDataBrewDataResourcePolicy IAM policy for DataBrew (console)**

1. Download the JSON for [samples/AwsGlueDataBrewDataResourcePolicy.json.zip](samples/AwsGlueDataBrewDataResourcePolicy.json.zip). 

1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/). 

1. In the navigation pane, choose **Policies**.

1. For each policy, choose **Create Policy**.

1. On the **Create Policy** screen, navigate to the **JSON** tab. 

1. Copy the policy JSON statement that you downloaded. Paste it over the sample statement in the editor.

1. Verify that the policy is customized to your account, security requirements, and required AWS resources. If you need to make changes, you can make them in the editor.

1. Choose **Review policy**.<a name="AwsGlueDataBrewDataResourcePolicy-cli-steps"></a>

**To define the AwsGlueDataBrewDataResourcePolicy IAM policy for DataBrew (AWS CLI)**

1. Download the JSON for [samples/AwsGlueDataBrewDataResourcePolicy.json.zip](samples/AwsGlueDataBrewDataResourcePolicy.json.zip). 

1. Customize the policy as described in the first step of the previous procedure.

1. Run the following command to create the policy.

   ```
   aws iam create-policy --policy-name AwsGlueDataBrewDataResourcePolicy --policy-document file://iam-policy-AwsGlueDataBrewDataResourcePolicy.json
   ```

# Configuring IAM policies for DataBrew
Configuring policies

Following, you can find details and examples about IAM policies that you can use with DataBrew. Details about the basic policies are provided here. Plus, there are more examples that are not required to use DataBrew. They are additional configurations that you might use in certain situations.

**Topics**
+ [

# AwsGlueDataBrewCustomUserPolicy
](iam-policy-to-use-databrew-console.md)
+ [

# AwsGlueDataBrewDataResourcePolicy
](iam-policy-for-data-resources-role.md)
+ [

# IAM policy to use Amazon S3 objects with DataBrew
](iam-policy-to-use-s3-for-data-resource-role.md)
+ [

# IAM policy to use encryption with DataBrew
](iam-policy-to-use-kms-encrypted-s3-for-data-resource-role.md)

# AwsGlueDataBrewCustomUserPolicy


The `AwsGlueDataBrewCustomUserPolicy` policy grants most of the permissions required to use the DataBrew console. Some of the resources that are specified in this policy refer to services that are used by DataBrew. These include names for AWS Glue Data Catalog, Amazon S3 buckets, Amazon CloudWatch Logs, and AWS KMS resources. It is similar to the AWS-managed policy named `AwsGlueDataBrewFullAccessPolicy`.

The following table describes the permissions granted by this policy.


|  **Action**  |  **Resource**  |  **Description**  | 
| --- | --- | --- | 
|   `"databrew:*"`   |   `"*"`   |  Grants permission to run all DataBrew API operations.  | 
|   `"glue:GetDatabases"`   `"glue:GetPartitions"`   `"glue:GetTable"`  `"glue:GetTables"`  `"glue:GetDataCatalogEncryptionSettings"`   |  "\$1"  |  Allows listing of AWS Glue databases and tables.  | 
|   `"dataexchange:ListDataSets"`   `"dataexchange:ListDataSetRevisions"`   `"dataexchange:ListRevisionAssets"`  `"dataexchange:CreateJob"`   `"dataexchange:StartJob"`   `"dataexchange:GetJob"`   |   `"*"`   |  Allows listing of AWS Data Exchange resources in datasets.  | 
|   `"kms:DescribeKey"`   `"kms:ListKeys"`   `"kms:ListAliases"`   |   `"*"`   |  Allows listing of AWS KMS keys to use for encryption of job output.  | 
|   `"kms:GenerateDataKey"`   |   `"arn:aws:kms:::key/key_ids"`   |  Allows encrypting of job output.  | 
|   `"s3:ListAllMyBuckets"`   `"s3:GetBucketCORS"`   `"s3:GetBucketLocation"`   `"s3:GetEncryptionConfiguration"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   | Allows listing of Amazon S3 buckets for projects, datasets, and jobs. Allows sending output files to S3. | 
|   `"sts:GetCallerIdentity"`   |   `"*"`   |  Get information about the current caller.  | 
|   `"cloudtrail:LookupEvents",`   |   `"*"`   |  Allow listing AWS CloudTrail events for datasets (data lineage).  | 
|   `"iam:ListRoles"`   `"iam:GetRole"`   |   `"*"`   |  Allows listing IAM roles to use for projects and jobs.  | 

# AwsGlueDataBrewDataResourcePolicy


The `AwsGlueDataBrewDataResourcePolicy` policy grants the permissions needed to connect to data and to configure DataBrew.

The following table describes the permissions granted by this policy.


|  **Action**  |  **Resource**  |  **Description**  | 
| --- | --- | --- | 
|   `"s3:GetObject"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   |  Allows you to preview your files.  | 
|  `"s3:PutObject"`  `"s3:PutBucketCORS"`  |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   |  Allows sending output files to S3.  | 
|   `"s3:DeleteObject"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   | Allows deleting an object created by DataBrew. | 
|   `"s3:ListBucket"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   | Allows listing of Amazon S3 buckets from projects, datasets, and jobs. | 
|  "kms:Decrypt"  |   `"arn:aws:kms:::key/key_ids"`   | Allows decrypting for encrypted datasets. | 
|   `"kms:GenerateDataKey"`   |   `"arn:aws:kms:::key/key_ids"`   |  Allows encrypting of job output.  | 
|   `"ec2:DescribeVpcEndpoints"`   `"ec2:DescribeRouteTables"`   `"ec2:DeleteNetworkInterface"`  `"ec2:DescribeNetworkInterfaces"`   `"ec2:DescribeSecurityGroups"`   `"ec2:DescribeSubnets"`   `"ec2:DescribeVpcAttribute"`   `"ec2:CreateNetworkInterface"`   |   `"*"`   |  Allows the setup of Amazon EC2 network items, such as virtual private clouds (VPCs), when running jobs and projects.  | 
|   `"ec2:DeleteNetworkInterface"`   |  "\$1"  | Allows deleting a network interface in a VPC. | 
|   `"ec2:CreateTags"`   `"ec2:DeleteTags"`   |   `"arn:aws:ec2:::network-interface/*", "arn:aws:ec2:::security-group/*"`   |  Allows creating and deleting tags. You need these permissions if you use an AWS Glue Data Catalog with a VPC enabled. DataBrew passes data to AWS Glue to run your jobs and projects. These permissions allow tagging of Amazon EC2 resources created for development endpoints. AWS Glue tags Amazon EC2 network interfaces, security groups, and instances with `aws-glue-service-resource`.  | 
|   `"logs:CreateLogGroup"`   `"logs:CreateLogStream"`   `"logs:PutLogEvents"`   |   `"arn:aws:logs:::log-group:/aws-glue-databrew/*"`   |  Allows writing logs to Amazon CloudWatch Logs  DataBrew writes logs to log groups whose names begin with `aws-glue-databrew`.  | 
|   `"lakeformation:GetDataAccess"`   |   `"*"`   |  Allows access to AWS Lake Formation, provided `"Glue":"GetTable"` is also allowed Using Lake Formation requires further configuration in the Lake Formation console.  | 

# IAM policy to use Amazon S3 objects with DataBrew
IAM policy for S3

The `AwsGlueDataBrewSpecificS3BucketPolicy` policy grants the permissions needed to access S3 on behalf of nonadministrative users.

Customize the policy as follows:

1. Replace the Amazon S3 paths in the policy so they point to the paths that you want to use. In the sample text, *`BUCKET-NAME-1/SPECIFIC-OBJECT-NAME`* represents a specific object or file. *`BUCKET-NAME-2/`* represents all objects (`*`) whose path name starts with `BUCKET-NAME-2/`. Update these to name the buckets that you are using.

1. (Optional) Use wildcards in the Amazon S3 paths to further restrict permissions. For more information, see [IAM policy elements: Variables and tags](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html) in the *IAM User Guide*. 

    **Security Best Practice**: To prevent unauthorized access to Amazon S3 buckets with similar names in other AWS accounts, include the `aws:ResourceAccount` condition key in your policy. This ensures that DataBrew can only access buckets within your own AWS account, even when using wildcard resource ARNs. Add the following condition to your policy statements: 

   ```
   "Condition": {
   "StringEquals": {
   "aws:ResourceAccount": "123456789012"
   }
   }
   ```

    Replace `123456789012` with your actual AWS account ID. 

   As part of doing this, you might restrict permissions for the actions `s3:PutObject` and `s3:PutBucketCORS`. These actions are required only for users who create DataBrew projects, because those users need to be able to send output files to S3. 

For more information and to see some examples of what you can add to an IAM policy for Amazon S3, see [Bucket Policy Examples](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html) in the *Amazon S3 Developer Guide.*

The following table describes the permissions granted by this policy.


|  **Action**  |  **Resource**  |  **Description**  | 
| --- | --- | --- | 
|   `"s3:GetObject"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   |  Allows you to preview your files.  | 
|   `"s3:PutObject"`   `"s3:PutBucketCORS"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   |  Allows sending output files to S3.  | 
|   `"s3:DeleteObject"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   | Allows deleting an object.  | <a name="AwsGlueDataBrewSpecificS3BucketPolicy-console-steps"></a>

**To define the AwsGlueDataBrewSpecificS3BucketPolicy IAM policy for DataBrew (console)**

1. Download the JSON for the [samples/AwsGlueDataBrewSpecificS3BucketPolicy.json.zip](samples/AwsGlueDataBrewSpecificS3BucketPolicy.json.zip) IAM policy. 

1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/). 

1. In the navigation pane, choose **Policies**.

1. For each policy, choose **Create Policy**.

1. On the **Create Policy** screen, navigate to the **JSON** tab. 

1. Paste in the policy JSON statement over the sample statement in the editor.

1. Verify that the policy is customized to your account, security requirements, and required AWS resources. If you need to make changes, you can make them in the editor.

1. Choose **Review policy**.<a name="AwsGlueDataBrewSpecificS3BucketPolicy-cli-steps"></a>

**To define the AwsGlueDataBrewSpecificS3BucketPolicy IAM policy for DataBrew (AWS CLI)**

1. Download the JSON for [samples/AwsGlueDataBrewSpecificS3BucketPolicy.json.zip](samples/AwsGlueDataBrewSpecificS3BucketPolicy.json.zip). 

1. Customize the policy as described in the first step of the previous procedure.

1. Run the following command to create the policy.

   ```
   aws iam create-policy --policy-name AwsGlueDataBrewSpecificS3BucketPolicy --policy-document file://iam-policy-AwsGlueDataBrewSpecificS3BucketPolicy.json
   ```

# IAM policy to use encryption with DataBrew
IAM policy for encryption

The `AwsGlueDataBrewS3EncryptedPolicy` policy grants the permissions needed to access S3 objects encrypted with AWS Key Management Service (AWS KMS) on behalf of nonadministrative users.

Customize the policy as follows:

1. Replace the Amazon S3 paths in the policy so that they point to the paths you want to use. In the sample text, *`BUCKET-NAME-1/SPECIFIC-OBJECT-NAME`* represents a specific object or file. *`BUCKET-NAME-2/`* represents all objects (`*`) whose path name starts with `BUCKET-NAME-2/`. Update these to name the buckets you are using.

1. (Optional) Use wildcards in the Amazon S3 paths to further restrict permissions. For more information, see [IAM policy elements: Variables and tags](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_variables.html). 

   As part of doing this, you might restrict permissions for the actions `s3:PutObject` and `s3:PutBucketCORS`. These actions are required only for users who create DataBrew projects, because those users need to be able to send output files to S3. 

   For more information and to see some examples of what you can add to an IAM policy for Amazon S3, see [Bucket Policy Examples](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html). 

1. Find the following resource ARNs in the `ToUseKms` file.

   ```
     "arn:aws:kms:AWS-REGION-NAME:AWS-ACCOUNT-ID-WITHOUT-DASHES:key/KEY-IDS",
   "arn:aws:kms:AWS-REGION-NAME:AWS-ACCOUNT-ID-WITHOUT-DASHES:key/KEY-IDS"
   ```

1. Change the example AWS account to your AWS account number (without hyphens).

1. Change the sample list to instead list the IAM roles you want to use. We recommend scoping your IAM policies to the smallest permissions set possible. However, you can allow your user to access all IAM roles, for example if you are using a personal learning account with sample data. To allow the list to access all IAM roles, change the sample list to one entry: `"arn:aws:iam::111122223333:role/*"`.

The following table describes the permissions granted by this policy.


|  **Action**  |  **Resource**  |  **Description**  | 
| --- | --- | --- | 
|   `"s3:GetObject"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   |  Allows you to preview your files.  | 
|   `"s3:ListBucket"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   | Allows listing of Amazon S3 buckets from projects, datasets, and jobs. | 
|   `"s3:PutObject"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   |  Allows sending output files to S3.  | 
|   `"s3:DeleteObject"`   |   `"arn:aws:s3:::bucket_name/*", "arn:aws:s3:::bucket_name"`   | Allows deleting an object created by DataBrew. | 
|  "kms:Decrypt"  |   `"arn:aws:kms:::key/key_ids"`   | Allows decrypting for encrypted datasets. | 
|   `"kms:GenerateDataKey*"`   |   `"arn:aws:kms:::key/key_ids"`   |  Allows encrypting of job output.  | <a name="AwsGlueDataBrewS3EncryptedPolicy-console-steps"></a>

**To define the AwsGlueDataBrewS3EncryptedPolicy IAM policy for DataBrew (console)**

1. Download the JSON for the [samples/AwsGlueDataBrewS3EncryptedPolicy.json.zip](samples/AwsGlueDataBrewS3EncryptedPolicy.json.zip) IAM policy. 

1. Sign in to the AWS Management Console and open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/). 

1. In the navigation pane, choose **Policies**.

1. For each policy, choose **Create Policy**.

1. On the **Create Policy** screen, navigate to the **JSON** tab. 

1. Paste in the policy JSON statement over the sample statement in the editor.

1. Verify that the policy is customized to your account, security requirements, and required AWS resources. If you need to make changes, you can make them in the editor.

1. Choose **Review policy**.<a name="AwsGlueDataBrewS3EncryptedPolicy-cli-steps"></a>

**To define the AwsGlueDataBrewS3EncryptedPolicy IAM policy for DataBrew (AWS CLI)**

1. Download the JSON for [samples/AwsGlueDataBrewS3EncryptedPolicy.json.zip](samples/AwsGlueDataBrewS3EncryptedPolicy.json.zip). 

1. Customize the policy as described in the first step of the previous procedure.

1. Run the following command to create the policy.

   ```
   aws iam create-policy --policy-name AwsGlueDataBrewS3EncryptedPolicy --policy-document file://iam-policy-AwsGlueDataBrewS3EncryptedPolicy.json
   ```