This repository contains Terraform configurations for deploying an AWS Aurora MySQL database cluster with automated secret management and security best practices.
The infrastructure includes:
- AWS Aurora MySQL cluster with multiple instances for high availability
- AWS Secrets Manager for credential management
- IAM roles and policies for secure access
- Security groups and subnet groups for network isolation
- CloudWatch logging enabled
- Automated backups configured
db/
└── terraform/
├── main.tf # Main infrastructure configuration
├── variables.tf # Input variables
├── outputs.tf # Output values
├── provider.tf # AWS provider configuration
├── data.tf # Data sources
├── locals.tf # Local variables and computed values
├── paramstore.tf # SSM Parameter Store configurations
└── config/
└── us-east-1/
├── dev.auto.tfvars # Development environment variables
└── dev_tfe_backend.config # Terraform Enterprise workspace configuration
- AWS Account with appropriate permissions
- Terraform Enterprise access
- VPC and subnet configuration in AWS
- AWS credentials configured
The following variables must be set in your environment or tfvars file:
cluster_identifier # Unique identifier for the Aurora cluster
database_name # Name of the database to create
master_username # Master username for the database
master_password # Master password for the database
vpc_id # VPC ID where the cluster will be deployed
subnet_ids # List of subnet IDs for the DB subnet group
product_name # Product name for resource tagging
env_name # Environment name (e.g., dev, prod)
env_type # Environment type
aws_region # AWS region for deployment-
Configure Terraform Enterprise Workspace
- Create a new workspace named
devlake-db-iac-dev1 - Set the working directory to
db/terraform - Configure VCS integration with this repository
- Create a new workspace named
-
Configure Variables
- Add all required variables in the Terraform Enterprise workspace
- Mark sensitive variables (like
master_password) as sensitive - Set environment variables for AWS credentials if not using workspace-specific credentials
-
Configure Backend
- The workspace is configured to use the backend configuration from
config/us-east-1/dev_tfe_backend.config - The workspace name is set to
devlake-db-iac-dev1
- The workspace is configured to use the backend configuration from
-
Deploy Infrastructure
- Queue a plan in Terraform Enterprise
- Review the plan output
- Apply the changes if the plan looks correct
-
Initialize Terraform
cd db/terraform terraform init -
Review Changes
terraform plan -var-file="config/us-east-1/dev.auto.tfvars" -
Apply Changes
terraform apply -var-file="config/us-east-1/dev.auto.tfvars"
-
Credential Management
- Master credentials stored in AWS Secrets Manager
- IAM role-based access to secrets
- Automatic secret rotation capability
-
Network Security
- VPC isolation
- Security group with configurable CIDR blocks
- Private subnet placement
-
Encryption
- Storage encryption enabled
- Secure credential storage
- IAM authentication support
- Automated backups enabled
- 7-day retention period (configurable)
- Backup window: 03:00-04:00 UTC (configurable)
- Weekly maintenance window: Monday 04:00-05:00 UTC (configurable)
- CloudWatch logging enabled for:
- Audit logs
- Error logs
- General logs
- Slow query logs
The following outputs are available:
cluster_endpoint: The cluster endpointcluster_reader_endpoint: The cluster reader endpointcluster_identifier: The cluster identifiercluster_port: The cluster portdatabase_name: The database namemaster_username: The master usernamesecurity_group_id: The security group IDsecret_arn: The ARN of the secret in AWS Secrets Manager
-
Resource Naming
- Resources follow a consistent naming convention
- Includes environment and region information
- Uses local variables for consistency
-
Tagging
- All resources are tagged with:
- Environment
- Project
- ManagedBy
- Owner
- CostCenter
- All resources are tagged with:
-
Security
- Least privilege principle for IAM roles
- Encrypted storage
- Secure credential management
- Network isolation
-
Common Issues
- VPC/Subnet configuration issues
- IAM permission issues
- Secret rotation failures
-
Logs
- Check CloudWatch logs for detailed information
- Review Terraform Enterprise run logs
- Monitor Aurora cluster metrics
For support or questions, please contact the platform team or create an issue in this repository.