Redshift IAM Authentication

Connect Monte Carlo to Redshift with AWS IAM instead of a database password.

Monte Carlo can connect to Amazon Redshift with AWS IAM instead of a stored database password. Monte Carlo gets temporary database credentials from AWS each time it connects, so no password is stored anywhere. This works with provisioned clusters and with Redshift Serverless.

🚧

Minimum agent version. IAM authentication through an agent requires agent version 1.15.2 or later. For the generic agent, use version 0.6.1 or later (image montecarlodata/agent:0.6.1-generic). Older agents fail the connection test with a message to upgrade the agent.

Choose an authentication type

Authentication typeWho signs in to RedshiftUse it when
Username and passwordA Redshift user with a passwordYou don't want to use IAM. This is the default and works on every deployment. See Creating a service account.
IAMThe IAM role your agent runs asYour agent runs in your AWS account and you can grant its role access to Redshift.
IAM assume roleAn IAM role you create, which Monte Carlo assumesMonte Carlo connects from its cloud, or you want Redshift access on a separate role from the agent's own, for example in another AWS account.

Where each type is available

How you provide the connection details depends on your deployment:

DeploymentUsername and passwordIAMIAM assume role
Monte Carlo cloud (no agent)✅ Connection form❌✅ Connection form
AWS agent or proxied agent on AWS✅ Connection form✅ Connection form✅ Connection form
Generic agent on AWS (for example Amazon ECS or EKS)✅ Self-hosted secret✅ Self-hosted secret✅ Self-hosted secret

The generic agent accepts only self-hosted credentials, so you set the authentication type in the secret you keep in your account. See Generic agent: set IAM in your secret.

IAM authentication is available in the connection form and the GraphQL API. The Monte Carlo CLI, Terraform provider and Agent Toolkit don't support it yet: they create Redshift connections with a username and password.

Step 1: Grant Redshift permissions to the IAM role

The role that calls Redshift depends on the authentication type:

  • IAM: the agent's own role. For the AWS agent, that is its Lambda execution role (open the agent's Lambda function in the AWS console, then Configuration → Permissions). For an agent on Amazon ECS, including Fargate, it is the ECS task role. For an agent on Amazon EKS, it is the role bound to the agent's service account with EKS Pod Identity or IRSA.
  • IAM assume role: the role you create for Monte Carlo in Step 2.

If you deployed the AWS agent with Monte Carlo's Terraform module, add the policy to the execution role as an inline policy. The module manages the role's attached managed policies exclusively, so its next terraform apply detaches a managed policy you attach yourself. The module has no input for extra policies, but its mcd_agent_execution_role output gives you the role:

resource "aws_iam_role_policy" "monte_carlo_redshift" {
  name   = "monte-carlo-redshift"
  role   = module.apollo.mcd_agent_execution_role.id
  policy = file("${path.module}/monte-carlo-redshift-policy.json")
}

Replace apollo with the name of your module block.

Add the policy that matches your Redshift setup to that role. Replace the region, account ID, cluster or workgroup and database with your own.

Provisioned cluster, with a database user

Use this when you fill in Database user. Monte Carlo signs in as that existing Redshift user.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "redshift:GetClusterCredentials",
      "Resource": [
        "arn:aws:redshift:us-east-1:123456789012:dbuser:my-cluster/monte_carlo",
        "arn:aws:redshift:us-east-1:123456789012:dbname:my-cluster/analytics"
      ]
    }
  ]
}

The dbuser resource names the cluster identifier and the database user, and the dbname resource names the cluster identifier and the database. Monte Carlo doesn't ask Redshift to create the user or add it to groups, so redshift:CreateClusterUser and redshift:JoinGroup aren't needed. The user must already exist with the grants in Step 3.

Provisioned cluster, without a database user

Use this when you leave Database user empty. Monte Carlo signs in as the IAM role itself, as the database user IAMR:<role name>.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "redshift:GetClusterCredentialsWithIAM",
      "Resource": "arn:aws:redshift:us-east-1:123456789012:dbname:my-cluster/analytics"
    }
  ]
}
Redshift Serverless

Monte Carlo always signs in as the IAM role itself, as the database user IAMR:<role name>. Database user is ignored on Redshift Serverless.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "redshift-serverless:GetCredentials",
      "Resource": "arn:aws:redshift-serverless:us-east-1:123456789012:workgroup/<workgroup ID>"
    }
  ]
}

The workgroup ARN uses the workgroup's ID, not its name. The Redshift Serverless console shows the full workgroup ARN on the workgroup's page.

Step 2 (IAM assume role only): Create the role Monte Carlo assumes

Skip this step for IAM.

  1. Create an IAM role and attach the Redshift policy from Step 1.
  2. Set its trust policy so the caller can assume it:
    • Monte Carlo cloud: trust Monte Carlo's collector as described in Creating IAM roles.
    • Agent: trust the agent's own role, from Step 1, by its ARN.
  3. Optional, recommended when the role is in another AWS account: require an External ID. Choose any value, add it to the trust policy, and enter the same value in External ID when you add the connection.
  4. Add the tag MonteCarloData with an empty value to the role. See When the role needs the MonteCarloData tag.

A trust policy for an agent, with an External ID:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/<agent role name>"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "sts:ExternalId": "<your external ID>"
        }
      }
    }
  ]
}

Leave out the Condition block if you don't use an External ID.

For an agent on Amazon ECS or EKS, such as the generic agent or the proxied agent on AWS, also allow the agent's own role to assume the new role. The task role in Monte Carlo's CloudFormation template for the proxied agent on ECS doesn't include this permission.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "sts:AssumeRole",
      "Resource": "arn:aws:iam::123456789012:role/monte-carlo-redshift"
    }
  ]
}

The execution role of the AWS agent deployed with Monte Carlo's CloudFormation template or Terraform module already allows sts:AssumeRole on roles tagged MonteCarloData, so it needs no change.

When the role needs the MonteCarloData tag

This applies to the AWS agent deployed with Monte Carlo's CloudFormation template or Terraform module. The agent can only assume roles that have a MonteCarloData tag with an empty value. The exception is a role in the same AWS account as the agent whose trust policy names the agent's execution role ARN: the agent can assume it without the tag. A role in another AWS account, or one whose trust policy trusts the whole account, needs the tag.

Adding the tag is always safe, so add it unless your tagging policies reject empty tags. Roles for agents on Amazon ECS or EKS (the generic agent, or the proxied agent on AWS) don't need the tag: their role's permissions are the ones you grant in Step 2.

Step 3: Grant database access

The Redshift user Monte Carlo signs in as needs the same access as a password user. See Creating a service account for what each grant is for.

With a database user (provisioned clusters): create the user without a password, then grant it access:

CREATE USER monte_carlo PASSWORD DISABLE;
ALTER USER monte_carlo SYSLOG ACCESS UNRESTRICTED;
GRANT SELECT ON svv_table_info TO monte_carlo;
GRANT USAGE ON SCHEMA <schema_name> [, …] TO monte_carlo;
GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> [, …] TO monte_carlo;
GRANT USAGE ON SCHEMA <external_schema> [, …] TO monte_carlo;
ALTER DEFAULT PRIVILEGES FOR USER <user_creating_tables> [, …] IN SCHEMA <schema_name> [, …] GRANT SELECT ON TABLES TO monte_carlo;

Without a database user, and on Redshift Serverless: Redshift names the database user after the IAM role: IAMR:<role name>. For IAM that is the agent's role. For IAM assume role it is the role Monte Carlo assumes. Redshift creates the user on its first sign-in, with no privileges. Create it ahead of time and grant it access. Write the role name exactly as it appears in IAM, and double-quote the user name in every statement: without quotes, Redshift keeps the IAMR: prefix but lowercases the rest of the name, so IAMR:MyRedshiftRole becomes IAMR:myredshiftrole. With quotes, the case is kept whatever enable_case_sensitive_identifier is set to:

CREATE USER "IAMR:monte-carlo-redshift" PASSWORD DISABLE;
ALTER USER "IAMR:monte-carlo-redshift" SYSLOG ACCESS UNRESTRICTED;
GRANT SELECT ON svv_table_info TO "IAMR:monte-carlo-redshift";
GRANT USAGE ON SCHEMA <schema_name> [, …] TO "IAMR:monte-carlo-redshift";
GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> [, …] TO "IAMR:monte-carlo-redshift";
GRANT USAGE ON SCHEMA <external_schema> [, …] TO "IAMR:monte-carlo-redshift";
ALTER DEFAULT PRIVILEGES FOR USER <user_creating_tables> [, …] IN SCHEMA <schema_name> [, …] GRANT SELECT ON TABLES TO "IAMR:monte-carlo-redshift";

You can also grant access through Redshift roles with the RedshiftDbRoles principal tag on the IAM role. See Redshift database roles with IAM in the AWS documentation.

Step 4: Add the connection

Connection form (Monte Carlo cloud, AWS agent, proxied agent on AWS)

Go to Settings → Integrations → Add, choose Amazon Redshift, and pick your deployment. Then fill in:

FieldShown forWhat to enter
Authentication typeAllUsername and password, IAM or IAM assume role. IAM is disabled unless the deployment is an agent in your AWS account.
Database userIAM, IAM assume roleOptional. An existing Redshift user on a provisioned cluster. Leave it empty to connect as the IAM role (IAMR:<role name>). On Redshift Serverless, leave it empty: Monte Carlo always connects as IAMR:<role name>, and a database user has no effect.
Host, Port, DatabaseAllAs for password authentication.
Role ARNIAM assume roleThe ARN of the role from Step 2, for example arn:aws:iam::123456789012:role/monte-carlo-redshift.
External IDIAM assume roleOptional. The External ID in the role's trust policy.
AWS regionIAM assume role (with the role fields), IAM (under Advanced — cluster overrides)The region of the cluster or workgroup. Defaults to the region in the host.
Cluster identifierIAM, IAM assume role, under Advanced — cluster overridesProvisioned clusters only.
Workgroup nameIAM, IAM assume role, under Advanced — cluster overridesRedshift Serverless only. Set a cluster identifier or a workgroup name, not both.

To change the authentication type of an existing connection, edit it from Settings → Integrations. Switching to an IAM type removes the stored password.

PrivateLink and custom hosts

Monte Carlo reads the region and the cluster or workgroup from a standard Redshift host:

  • Provisioned: <cluster>.<id>.<region>.redshift.amazonaws.com
  • Serverless: <workgroup>.<account ID>.<region>.redshift-serverless.amazonaws.com

Other hosts don't carry them, so set them under Advanced — cluster overrides: Cluster identifier or Workgroup name, and AWS region. This includes PrivateLink and custom DNS endpoints. It also includes Redshift-managed VPC endpoints: their host starts with the endpoint name, not the cluster or workgroup name, so set the cluster identifier or workgroup name even though Monte Carlo still reads the region.

If the agent has no internet access, it also needs interface VPC endpoints, with private DNS turned on, for the AWS APIs it calls:

  • com.amazonaws.<region>.redshift for provisioned clusters, or com.amazonaws.<region>.redshift-serverless for Redshift Serverless.
  • com.amazonaws.<region>.sts for IAM assume role. Use the cluster's or workgroup's region: the agent calls the STS endpoint in that region, even when it runs in another region.
  • com.amazonaws.<region>.secretsmanager if the agent reads self-hosted credentials from AWS Secrets Manager.

Generic agent: set IAM in your secret

The generic agent reads the connection details from the self-hosted credentials secret you keep in your account. Put the authentication type and the IAM settings in that secret's connect_args:

{
  "connect_args": {
    "host": "my-endpoint-vpce-0a1b2c3d4e5f67890.abc123xyz789.us-east-1.redshift.amazonaws.com",
    "port": "5439",
    "dbname": "analytics",
    "auth_type": "iam",
    "aws_region": "us-east-1",
    "cluster_identifier": "my-cluster"
  }
}

With self-hosted credentials Monte Carlo doesn't read the region or the cluster or workgroup from the host, so the secret always needs aws_region and either cluster_identifier or workgroup_name. See Redshift IAM in self-hosted credentials for every key and an example for each authentication type. Then register the secret as described in Self-hosted credentials.

By default, the agent caches the secret's value for up to 5 minutes, so a change to the secret can take up to 5 minutes to apply.

Troubleshooting

When Monte Carlo can't get temporary credentials, only the Connect to Redshift step of the connection test shows the specific error, after "Could not connect to Redshift.". The other steps then show "An internal error has occurred during validation". Look up the Connect to Redshift message below.

Read the error in the connection test result in Monte Carlo, not in the agent's logs. The agent redacts whole log lines that contain words such as "credential", "auth", "token" or "key", so these errors show as redacted there, while Monte Carlo receives the full message.

"IAM authentication requires an AWS agent deployment"

You chose IAM on a deployment where Monte Carlo doesn't run as your role: Monte Carlo's cloud or a generic agent. Use IAM assume role instead or, with a generic agent, set "auth_type": "iam" in your self-hosted secret.

"redshift:GetClusterCredentials failed: AccessDenied", "redshift:GetClusterCredentialsWithIAM failed: AccessDenied" or "redshift-serverless:GetCredentials failed: AccessDeniedException"

The role that calls Redshift lacks the permission for that action. On Monte Carlo cloud the same error reads "Unable to get temporary Redshift credentials from AWS (assume role, then …)", followed by the AWS error. Check that the policy is attached to the right role (the agent's own role for IAM, the assumed role for IAM assume role) and that its resources match your region, account, cluster identifier or workgroup ID, database and database user. With a database user, Monte Carlo calls GetClusterCredentials; without one, GetClusterCredentialsWithIAM.

"sts:AssumeRole failed: AccessDenied"

Monte Carlo couldn't assume the role in Role ARN. On Monte Carlo cloud the error reads "Unable to get temporary Redshift credentials from AWS (assume role, then …)" with an AssumeRole AccessDenied error. Check that:

  • The role's trust policy names the caller: the agent's own role, or Monte Carlo's collector for the Monte Carlo cloud.
  • External ID matches the sts:ExternalId value in the trust policy exactly, or both are empty.
  • The role has the MonteCarloData tag, if it is in another account than the AWS agent or trusts the whole account.
  • For an agent on Amazon ECS or EKS, the agent's own role allows sts:AssumeRole on the role.

"Redshift IAM authentication can't derive the cluster or workgroup from host"

The host isn't a standard Redshift host, such as a PrivateLink endpoint. Set Cluster identifier or Workgroup name, and AWS region, under Advanced — cluster overrides. See PrivateLink and custom hosts.

"Agent needs to be upgraded, required version" or "This agent version doesn't support Redshift IAM authentication"

Upgrade the agent to the minimum version at the top of this page, or later. With self-hosted credentials the message can read "The agent couldn't build Redshift credentials from the secret because it has no password": if the secret sets auth_type, upgrade the agent; otherwise add the password to the secret.

"'assumable_role' is only used with auth_type 'iam_assume_role'; remove it or change auth_type"

Your self-hosted secret sets "auth_type": "iam" and also an assumable_role. IAM always connects as the agent's own role. Remove assumable_role, or set "auth_type": "iam_assume_role" to have the agent assume that role.

"unsupported 'auth_type', expected one of ['iam', 'iam_assume_role']"

The auth_type in your self-hosted secret isn't a value the agent knows. Values are case-sensitive: use password (or leave auth_type out), iam or iam_assume_role. A secret with an unknown auth_type and a password connects with the password.

When you register the secret, the credential check can report the same problem as a schema error that lists the shapes it accepts.

"'aws_region' is required", "exactly one of 'cluster_identifier' (provisioned cluster) or 'workgroup_name' (Redshift Serverless) is required" or "'assumable_role' is required with auth_type 'iam_assume_role'"

Your self-hosted secret is missing a key. Add it to the secret's connect_args, then wait up to 5 minutes for the agent to read the new value.

The connection times out with ConnectTimeoutError or EndpointConnectionError

The agent can't reach an AWS API. If the agent has no internet access, add the interface VPC endpoints it needs.

The connection test passes the sign-in but fails on permissions

Monte Carlo signed in, but the database user lacks grants. If you left Database user empty or use Redshift Serverless, grant access to "IAMR:<role name>", as in Step 3.

Details and edge cases

Temporary credentials. Monte Carlo asks AWS for new database credentials each time it connects. They are short-lived and never stored.

IAM doesn't take a role. With IAM, Monte Carlo always uses the agent's own role. A self-hosted secret with "auth_type": "iam" and an assumable_role is rejected before any AWS call, rather than silently connecting as the agent's role.

All-digit values. Write every value in a self-hosted secret as a JSON string, including all-digit ones such as an External ID that is an AWS account ID: "external_id": "123456789012".

Regional STS. With IAM assume role through an agent, the agent calls the STS endpoint in the cluster's or workgroup's region, never the global sts.amazonaws.com endpoint.

Password fields with IAM. With an IAM authentication type, user and password in a self-hosted secret are ignored. Use db_user to choose an existing database user on a provisioned cluster.

Connection Auth Rules. IAM authentication doesn't need a Connection Auth Rule. The agent's default Redshift handling gets the temporary credentials when auth_type is iam or iam_assume_role.


Did this page help you?