Skip to content

Instantly share code, notes, and snippets.

@chrisguitarguy
Last active January 17, 2019 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisguitarguy/49be555e1870e815ee991ff45ca5d637 to your computer and use it in GitHub Desktop.
Save chrisguitarguy/49be555e1870e815ee991ff45ca5d637 to your computer and use it in GitHub Desktop.
Cross Account Redshift UNLOAD/COPY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::{REDSHIFT_ACCOUNT_ID}:root"
},
"Action": [
"s3:PutObject",
"s3:ListBucket",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::CHANGEME/*",
"arn:aws:s3:::CHANGEME"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::{REDSHIFT_ACCOUNT_ID}:role/{ROLE_NAME}"
},
"Action": [
"s3:PutObject",
"s3:ListBucket",
"s3:GetObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::CHANGEME/*",
"arn:aws:s3:::CHANGEME"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3",
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::CHANGEME/*",
"arn:aws:s3:::CHANGEME"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowRedshiftAssume",
"Effect": "Allow",
"Principal": {
"Service": "redshift.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
UNLOAD ('SELECT 1')
TO 's3://CHANGEME/prefix-'
CREDENTIALS 'aws_iam_role=arn:aws:iam::{REDSHIFT_ACCOUNT_ID}:role/{ROLE_NAME}';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment