Provisioning Amazon RDS through Terraform
Table of contents
This blog is about terraform AWS RDS provisioning with secret manager integration.
Terraform RDS Workflow
The following image shows the RDS provisioning workflow using Terraform.
Here is the workflow explanation.
Terraform code is developed, tested, and pushed to GitHub
Once you execute terraform init, the terraform code is pulled to the workstation or server where you have the terraform and AWS CLI configured.
Execute terraform plan, pass the variables required for RDS provisioning.
RDS gets provisioned after executing terraform apply and terraform remote state file is stored in S3 bucket.
The password for RDS will be automatically created and stored in the AWS secrets manager. You can also use direct passwords instead of secret manager. However, it is not recommended to keep secrets in terraform code.
Once the RDS instance is provisioned; the RDS endpoint, address, and secret manager's secret arn get added to the terraform output. With the secret arn, applications can retrieve the DB username and password from the secrets manager.
Applications can connect with DB using this RDS endpoint.
Terraform RDS Code Repository
You can access my GitHub repo for RDS terraform module by clicking here. To get the payload required for RDS terraform module, click here.
Conclusion
In this blog, we looked at terraform aws rds provisioning. Some things to keep in mind.
RDS supports password management using a secrets manager. It automatically creates and stores the username and password during provisioning.
Each secret in the secret manager costs $.50
The secret created by RDS cannot be modified separately. Also, by default, password rotation is enabled for the master password with a rotation schedule of 7 days. That value can be modified in the secrets manager.
Subscribe to my newsletter
Read articles from VISHAL CHAUHAN directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by