{"record":{"id":"f235b46420c36052","repo":"cube-js/cube","slug":"cubejs-db-name-is-required-for-iam-authentication","errorCode":null,"errorMessage":"CUBEJS_DB_NAME is required for IAM authentication","messagePattern":"CUBEJS_DB_NAME is required for IAM authentication","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-redshift-driver/src/RedshiftIAMCredentialsProvider.ts","lineNumber":47,"sourceCode":"  protected readonly awsCredentials?: ReturnType<typeof fromTemporaryCredentials>;\n\n  protected cached: CachedCredentials | null = null;\n\n  protected inflightRefresh: Promise<CachedCredentials> | null = null;\n\n  public constructor(options: RedshiftIAMCredentialProviderOptions) {\n    if (!options.region) {\n      throw new Error('CUBEJS_DB_REDSHIFT_AWS_REGION is required for IAM authentication');\n    }\n\n    if (!options.clusterIdentifier) {\n      throw new Error(\n        'CUBEJS_DB_REDSHIFT_CLUSTER_IDENTIFIER is required for IAM authentication'\n      );\n    }\n\n    if (!options.dbName) {\n      throw new Error(\n        'CUBEJS_DB_NAME is required for IAM authentication'\n      );\n    }\n\n    this.region = options.region;\n    this.clusterIdentifier = options.clusterIdentifier;\n    this.dbName = options.dbName;\n\n    if (options.assumeRoleArn) {\n      this.awsCredentials = fromTemporaryCredentials({\n        params: {\n          RoleArn: options.assumeRoleArn,\n          ...(options.assumeRoleExternalId && { ExternalId: options.assumeRoleExternalId }),\n        },\n      });\n    }\n  }\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-redshift-driver/src/RedshiftIAMCredentialsProvider.ts#L29-L65","documentation":"Temporary credentials from GetClusterCredentials are scoped to a specific database. The provider requires options.dbName so it can request credentials for the right database, and throws at construction if it is absent.","triggerScenarios":"new RedshiftIAMCredentialsProvider({...}) with region and clusterIdentifier set but dbName undefined — typically CUBEJS_DB_NAME unset.","commonSituations":"IAM auth enabled but the database name env var missing or renamed; deploying with only connection-string style config that the IAM provider does not read.","solutions":["Set CUBEJS_DB_NAME to the target Redshift database","Pass dbName explicitly in RedshiftIAMCredentialProviderOptions","Ensure the database exists and the IAM role is allowed GetClusterCredentials for that dbuser/dbname"],"exampleFix":"// before\nCUBEJS_DB_REDSHIFT_AWS_REGION=us-east-1\nCUBEJS_DB_REDSHIFT_CLUSTER_IDENTIFIER=my-cluster\n// after\nCUBEJS_DB_REDSHIFT_AWS_REGION=us-east-1\nCUBEJS_DB_REDSHIFT_CLUSTER_IDENTIFIER=my-cluster\nCUBEJS_DB_NAME=analytics","handlingStrategy":"validation","validationCode":"if (!process.env.CUBEJS_DB_NAME) {\n  throw new Error('CUBEJS_DB_NAME must be set for IAM auth');\n}","typeGuard":"function hasDbName(o: { dbName?: string }): o is { dbName: string } {\n  return typeof o.dbName === 'string' && o.dbName.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always set CUBEJS_DB_NAME alongside IAM auth variables","Verify the database exists on the cluster before deploying","Add a startup validation that all three IAM vars are present"],"tags":["redshift","iam","configuration","missing-env-var"],"backgroundTag":"missing-env-var","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}