Redshift
Requirements
Name
Description
1
Grant Teleskope IAM Access to Redshift
Terraform
resource "aws_iam_role_policy_attachment" "redshift_read_policy" {
role = "TeleskopeRole"
policy_arn = "arn:aws:iam::aws:policy/AmazonRedshiftReadOnlyAccess"
}
resource "aws_iam_role_policy_attachment" "redshift_data_policy" {
role = "TeleskopeRole"
policy_arn = "arn:aws:iam::aws:policy/AmazonRedshiftDataFullAccess"
}
# Optional: required if using Redshift IAM database authentication (no stored password).
data "aws_caller_identity" "current" {}
resource "aws_iam_policy" "redshift_iam_auth" {
name = "teleskope-redshift-iam-auth"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "RedshiftIamAuth"
Effect = "Allow"
Action = [
"redshift:GetClusterCredentials",
"redshift:GetClusterCredentialsWithIAM"
]
Resource = [
"arn:aws:redshift:${var.aws_region}:${data.aws_caller_identity.current.account_id}:cluster:${var.redshift_cluster_identifier}",
"arn:aws:redshift:${var.aws_region}:${data.aws_caller_identity.current.account_id}:dbuser:${var.redshift_cluster_identifier}/teleskope"
]
}
]
})
}
resource "aws_iam_role_policy_attachment" "redshift_iam_auth" {
role = "TeleskopeRole"
policy_arn = aws_iam_policy.redshift_iam_auth.arn
}2
Teleskope Database User
Create Database User
CREATE USER teleskope WITH PASSWORD '****PASSWORD****'CREATE USER teleskope WITH SYSLOG ACCESS UNRESTRICTED;aws redshift associate-iam-roles \ --cluster-identifier my-redshift-cluster \ --iam-role-arn arn:aws:iam::<account-id>:role/TeleskopeRole
Grant Read Access
GRANT SELECT ON svv_all_schemas TO teleskope_ro;
GRANT SELECT ON svv_table_info TO teleskope_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA pg_catalog
-- Grant select to each Redshift schema
GRANT USAGE ON SCHEMA {schema} TO teleskope;
GRANT SELECT ON ALL TABLES IN SCHEMA {schema} TO teleskope;Grant Write Access
GRANT UPDATE, DELETE ON ALL TABLES IN SCHEMA {schema} TO teleskope;SSH Tunnel (Optional)
echo "<TELESKOPE_PUBLIC_KEY>" >> ~/.ssh/authorized_keyschmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
Last updated
Was this helpful?
