Terraform AWS module for RDS encrypted DB

Generic repository for a terraform module for AWS RDS encrypted database, by default Postgres

Image of Terraform

Table of content

Intro

Module that creates:

  • Security Group for RDS, and opens egress traffic on all ports for a given CIDR
  • Creates a KMS key (and an alias for it) used to encrypt the RDS instance
  • DB subnet and parameter dedicated groups
  • DB instance (the RDS)

Usage

Example usage:

module "dev_db_encrypted" {
  source            = "github.com/diogoaurelio/terraform-module-aws-storage-rds-encrypted"
  version           = "v0.0.2"

  environment       = "dev"
  project           = "analytics"
  region            = "eu-west-1"
  vpc_id            = "vpc-123"
  subnet_ids        = "subnet-123"
  engine            = "postgres"
  engine_version    = "9.6.6"
  instance_class    = "db.t2.medium"
  db_name           = "mydb"
  username          = "master"
  password          = "supersecret"
  apply_immediately = false
  size              = "20"

  # open SG income traffic for following CIDR blocks
  income_cidr_blocks = [ "10.10.1.0/24" ]
}

Release log

Whenever you bump this module's version, please add a summary description of the changes performed, so that collaboration across developers becomes easier.

  • version v0.0.1 - first module release

Module versioning & git

To update this module please follow the following proceedure:

  1. make your changes following the normal git workflow
  2. after merging the your changes to master, comes the most important part, namely versioning using tags:
git tag v0.0.2
  1. push the tag to the remote git repository:
git push origin master tag v0.0.2

Local terraform setup

brew install terraform
  • In order to automatic format terraform code (and have it cleaner), we use pre-commit hook. To install pre-commit.
  • Run pre-commit install to setup locally hook for terraform code cleanup.
pre-commit install