Amazon Redshift
This article is for data engineers and DevOps
This guide will provide you with the steps you need to perform in order to give your Amazon Redshift access to read data from S3 bucket used for Data Export.
Before you continue with this guide please make sure that you have completed the Data Export for Amazon S3 since it is requirement for ETL for Amazon Redshift.
IAM Policy for Redshift
1. Redshift → S3 Policy
To load data from S3 bucket into Redshift, you have to do the following steps. This will add permissions for your Redshift cluster to read data from a single S3 bucket.
-
Login as Administrator into your AWS account
-
Go to Policies page https://us-east-1.console.aws.amazon.com/iamv2/home#/policies
-
Click Create policy
-
Click JSON tab item
-
Enter this manifest:
-
Replace
YourAttributionS3Bucket
with actual name of your bucket used for Attribution Data Export{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "s3:Get*", "s3:List*" ], "Resource": [ "arn:aws:s3:::YourAttributionS3Bucket/*", "arn:aws:s3:::YourAttributionS3Bucket" ] } ] }
-
Click Next: Tags
-
Click Next: Review
-
Add name:
AttributionS3BucketReadOnly
-
Click Create policy
2. AWS Glue policy:
- Go to "Policies" page: https://us-east-1.console.aws.amazon.com/iamv2/home#/policies
- Create a new policy named
AttributionGlue
with this JSON content:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ATBGluePolicy",
"Effect": "Allow",
"Action": [
"glue:CreateTable",
"glue:CreateDatabase",
"glue:DeleteTable",
"glue:GetTable"
],
"Resource": "*"
}
]
}
3. Create a role and attach it to Redshift
- Go to Roles page: https://us-east-1.console.aws.amazon.com/iamv2/home#/roles
- Click Create role
- Leave AWS Service selected
- Select Redshift in Other Services
- Click Redshift - Customizable
- Click Next
- On the Add permissions page:
- Select
AttributionS3BucketReadOnly
andAttributionGlue
policies - Click Next
- Select
- Enter role name:
AttributionS3DataLoader
- Click Create role
- Copy ARN of the created role which should look like
arn:aws:iam::0000000000:role/AttributionS3DataLoader
(you will need to let us know this string).
- Go to your Redshift cluster settings
- Click Properties tab
- Click Associate IAM role
- Select
AttributionS3DataLoader
role (and additional roles if you need them) - Click Associate IAM roles
4. Create Redshift user
- Go to redshift query editor: https://us-east-1.console.aws.amazon.com/sqlworkbench/home?region=us-east-1#/client
- Create a user and DB for Attribution data loader:
CREATE USER attribution WITH PASSWORD 'PRE_ENCRYPTED_PASSWORD_GOES_HERE';
CREATE DATABASE attribution WITH OWNER attribution;
We will generate a strong password and send it to you in pre-encrypted form.
If you want to generate password yourself, please use this SQL code:
SELECT 'md5' || md5('PLAIN_PASSWORD' || 'attribution');
More info: https://docs.aws.amazon.com/redshift/latest/mgmt/authorizing-redshift-service.html
Once described steps above are completed contact Attribution support to enable ETL service.
Updated 6 months ago