Configure AWS IAM Authentication for Aurora and RDS
AWS IAM authentication for Aurora and RDS replaces static database passwords with temporary, cryptographically signed tokens that expire after 15 minutes. This eliminates the need to store database cr
Prerequisites
Ensure you have the following prerequisites in place:
AWS Aurora or RDS instance: PostgreSQL or MySQL engine with IAM authentication enabled. Go to Enabling and disabling IAM database authentication to enable IAM authentication on your cluster or instance.
Harness Delegate 3.0 on ECS Fargate: Delegate running on AWS ECS Fargate with a task role that includes
rds-db:connectpermission. Go to Install Harness Delegate to set up your delegate.Task role ARN configured: The
HARNESS_ECS_BUILD_TASK_ROLE_ARNenvironment variable must be set in the delegate configuration with the ARN of the ECS task role used for IAM authentication.SSL certificates configured: Custom SSL certificates must be configured in the Delegate 3.0 ECS task definition for secure database connections. Go to Configure SSL certificates on ECS to set up certificate mounting.
Database user with IAM role: A database user created with the
rds_iamrole granted. This user will authenticate using IAM tokens instead of passwords.
Understand AWS Aurora and RDS architectures
Before configuring IAM authentication, it is important to understand the difference between RDS and Aurora architectures, as this affects how you configure connection strings and IAM policies.
AWS RDS (relational database service)
RDS is a managed database service that automates database administration tasks such as backups, patching, and scaling. It follows a traditional single-server model.
Engines supported: PostgreSQL, MySQL, MariaDB, Oracle, SQL Server
Architecture: Single primary instance with optional Multi-AZ standby replica
Storage: Uses EBS (Elastic Block Store) volumes attached to the instance
Connection: Connect directly to the instance endpoint
IAM policy scope: Instance-level resource ARN
AWS Aurora
Aurora is a cloud-native database engine built specifically for AWS. It uses a distributed storage architecture that separates compute from storage.
Engines supported: MySQL-compatible and PostgreSQL-compatible
Architecture: Always deployed as a cluster with one writer and optional reader instances
Storage: Data replicated 6 times across 3 Availability Zones, self-healing and auto-scaling
Connection: Connect to the cluster endpoint or specific instance endpoints
IAM policy scope: Cluster-level resource ARN (not instance-level)
Understand how IAM authentication works
IAM authentication replaces static passwords with temporary authentication tokens that are cryptographically signed by AWS.
Authentication flow
The following steps describe how IAM authentication works during a database connection:
Token request: The Harness Delegate requests an authentication token from AWS STS (Security Token Service) using its IAM role.
Token generation: AWS generates a cryptographically signed token that is valid for 15 minutes. The token includes the database username, cluster identifier, region, and port.
Connection attempt: The delegate connects to the database using the database username and the token as the password.
Token validation: The database engine validates the token signature by contacting AWS. If AWS confirms the signature is valid for the specified cluster and username, access is granted.
Token expiration: After 15 minutes, the token expires and a new token must be generated for subsequent connections.
Why username is required in the token
The username is cryptographically signed into the authentication token by AWS. When the database validates the token, it verifies that the username in the connection attempt matches the username signed into the token. This prevents token reuse across different database users and provides strong identity binding.
For example - If AWS signs a token for username harness_iam_user, you cannot use that token to authenticate as admin_user. The database will reject the connection immediately because the token signature does not match the login username.
Configure ECS task role for IAM authentication
IAM authentication for Aurora and RDS requires configuring an ECS task role with the rds-db:connect permission. This task role is used by containers during pipeline execution to generate temporary authentication tokens.
Create IAM policy for database access
Create an IAM policy that grants the rds-db:connect action at the cluster level for Aurora databases.
IAM policy structure for Aurora:
Resource ARN format:
Find your Aurora cluster resource ID
The cluster resource ID is not the same as the cluster identifier shown in the AWS console.
To find the cluster resource ID:
Attach policy to ECS task role
Attach the IAM policy to the task role that will be used for database authentication:
In the AWS IAM console, locate the ECS task role that will be specified in the
HARNESS_ECS_BUILD_TASK_ROLE_ARNenvironment variable.Create a new inline policy or managed policy using the IAM policy JSON above.
Replace
REGION,ACCOUNT_ID,CLUSTER_RESOURCE_ID, andDATABASE_USERNAMEwith your actual values.Attach the policy to the ECS task role.
Configure Delegate with task role ARN
Set the following environment variable in your Harness Delegate 3.0 configuration to specify which task role ARN should be used for IAM authentication:
This environment variable must point to the ECS task role that has the rds-db:connect permission attached. During pipeline execution, Harness uses this task role to generate temporary IAM authentication tokens for database connections.
IMPORTANT
Without the HARNESS_ECS_BUILD_TASK_ROLE_ARN environment variable, IAM authentication will fail. This variable is required in Delegate 3.0 configurations to enable IAM token generation during pipeline execution.
Create database user with IAM authentication
After configuring the IAM policy in AWS, you must create a corresponding database user in your Aurora or RDS database and grant it the special rds_iam role. This role is a pre-created PostgreSQL or MySQL role that marks the user as eligible for IAM token authentication. Without this grant, the database will reject all IAM token authentication attempts, even if the IAM policy is correctly configured.
Create a database user and grant the rds_iam role to enable IAM authentication for that user.
Use direct SQL commands
Connect to your database using the master user credentials and run:
Configure shared ownership for multi-user access
If you need both the master user (for example, postgres) and the IAM user (for example, harness_iam_user) to run Liquibase migrations interchangeably, configure a shared role group to prevent ownership conflicts.
Why shared ownership is needed
When one user creates the databasechangelog and databasechangeloglock tables, that user becomes the owner. If the other user tries to update those tables later, it may fail due to insufficient permissions. A shared role group solves this by making both users co-owners.
Configure shared role group
Run the following SQL commands using the master user credentials to set up shared ownership:
This approach allows both users to create, modify, and deploy schema changes without ownership conflicts.
Configure SSL certificates on ECS
When using IAM authentication with Aurora or RDS, the connection requires SSL. If your database uses a custom or private CA certificate, you must mount the certificate into the delegate containers at runtime using ECS secret and volume mappings.
Add SSL certificate configuration to ECS task definition
Add the following entries to your Harness Delegate 3.0 ECS task definition. These entries pull the CA certificate from AWS Secrets Manager and mount it into the container file system.
Secrets entry:
Replace REGION, ACCOUNT_ID, and YOUR_SECRET_NAME with your actual values.
How certificate mounting works
The following environment variables control how the certificate is pulled and mounted:
secretsblock: Pulls the secret value from AWS Secrets Manager at container startup and exposes it asHARNESS_CERT_0inside the container.HARNESS_SECRET_FILE_MAPPINGS: Maps a Secrets Manager secret (identified by theHARNESS_CERT_0name from thesecretsblock) to a file path inside the container. The value format isSECRET_NAME:FILE_PATH.HARNESS_CI_MOUNT_VOLUMES: Propagates the mounted certificate file into spawned build task containers during pipeline execution. The value format isHOST_PATH:CONTAINER_PATH. Use the same path on both sides to mount the file at the same location in the build container.
Configure JDBC connector in Harness
Configure your Harness JDBC connector to use IAM authentication with the AWS JDBC wrapper.
Connection URL format
The connection URL must use the aws-wrapper prefix and include IAM plugin parameters:
Aurora cluster endpoint:
Aurora instance endpoint:
RDS instance endpoint:
Required URL components
The IAM-enabled connection URL must include the following components:
Prefix:
jdbc:aws-wrapper:postgresql://(replaces standardjdbc:postgresql://)Parameter:
wrapperPlugins=iam(enables IAM authentication plugin)SSL parameters:
ssl=true&sslmode=require(IAM authentication requires SSL)
Configure connector in Harness UI
Complete the following steps to configure the JDBC connector:
Go to Database DevOps > Connectors > New Connector > Database.
Select JDBC as the connector type.
In the JDBC URL field, enter the IAM-enabled connection string using the
aws-wrapperprefix.In the Authentication type, select the Use Delegate Credentials option.
In the Username field, enter the database username (for example,
harness_iam_user).Select the Harness Delegate that has the task role ARN configured with the correct RDS/Aurora permission (for example
rds-db:connectpermission).Click Test Connection to verify the configuration.
Click Save.
Verify IAM authentication setup
Test your IAM authentication configuration before using it in production pipelines.
Test connection from Delegate
SSH into your Harness Delegate host and verify IAM token generation:
If token generation fails, verify:
The ECS task role specified in
HARNESS_ECS_BUILD_TASK_ROLE_ARNhasrds-db:connectpermissionThe hostname, port, region, and username are correct
The delegate can reach AWS STS endpoints
Test connection using psql
Verify in Harness pipeline
Create a test pipeline with a Liquibase or Flyway step:
Use the IAM-enabled JDBC connector.
Run a simple changeset (for example,
SELECT 1).Check the execution logs for successful connection and authentication.
Troubleshooting
Next steps
With IAM authentication configured, you can:
Go to Harness Database DevOps onboarding guide to create your first schema and pipeline.
Go to Configure SSL for database connections to learn about SSL certificate management.
Go to Automatic and custom rollbacks to configure rollback strategies for failed migrations.
Last updated
Was this helpful?