Terraform Enterprise (TFE) running on an Amazon EKS cluster can now(version 1.1.0) authenticate to an AWS RDS PostgreSQL database without storing or providing a database password. Instead, it uses AWS IAM–based authentication, improving security posture and reducing secret management overhead.
This article walks through how to configure a TFE EKS deployment to connect to PostgreSQL pass wordlessly using AWS IAM, leveraging the supported TFE environment variables.
At a high level, the authentication flow looks like this:
-
TFE runs on EKS using a Kubernetes Service Account.
-
PostgreSQL (RDS) is configured to allow IAM authentication.
-
TFE uses AWS SDK calls to generate a temporary auth token instead of a static password.
-
The token is used to authenticate to PostgreSQL at runtime.
No database passwords are stored in:
-
Kubernetes Secrets
-
Terraform variables
-
TFE configuration files
Prerequisites
Before configuring TFE, ensure the following are in place:
1. Terraform Enterprise on EKS
-
TFE deployed on EKS (Helm or operator-based deployment)
-
EKS cluster has OIDC provider enabled
- TFE version 1.1.0
2. PostgreSQL on AWS RDS
-
PostgreSQL engine that supports IAM authentication
-
rds_iamenabled on the database -
Database user created for IAM authentication
3. IAM Role for TFE (IRSA)
-
IAM role assumable by the TFE Kubernetes Service Account
-
Permissions to:
-
rds-db:connect -
sts:GetCallerIdentity
-
Solution
Step 1: Enable IAM Authentication on RDS PostgreSQL
Enable IAM authentication on the RDS instance:
Step 2: Create an IAM-Authenticated PostgreSQL User
Connect to PostgreSQL as an admin and create a user mapped to IAM:
Important:
The PostgreSQL username must exactly match the IAM database user name used by TFE.
Step 3: Create a policy for EKS node group IAM role
Attach the following policy to the IAM policy used by EKS node group role :
DB_policy.json
Ensure the Kubernetes node group role is assigned with the policy DB_policy.json .
Step 4: Configure TFE for Password less PostgreSQL Authentication
Set the following TFE environment variables in your EKS deployment (Helm values or Kubernetes manifests):
Key Notes
-
Do not set
TFE_DATABASE_PASSWORD -
TFE will automatically generate a short-lived authentication token using AWS IAM
-
Tokens are refreshed automatically by TFE
Step 5: Restart TFE Pods
Apply the changes and restart TFE:
Monitor logs to confirm successful authentication:
You should see successful database connection logs without password usage.
Security Benefits
-
Eliminates long-lived database credentials
-
IAM policies provide fine-grained access control
-
Automatic token rotation handled by AWS
-
Aligns with enterprise security and compliance standards
Common Troubleshooting Tips
| Issue | What to Check |
|---|---|
| Authentication failed | PostgreSQL user name mismatch |
| Permission denied | IAM policy missing rds-db:connect |
| Token expired | Ensure region is correctly set |
| TFE stuck on startup | Confirm IRSA is correctly configured |
Conclusion
By combining EKS IRSA, RDS IAM authentication, and TFE’s passwordless database support, you can securely run Terraform Enterprise without managing PostgreSQL passwords.
This approach is recommended for production-grade, security-conscious deployments.