Using Terraform to Build Oracle Databases in AWS RDS

Our place uses a number of classic Oracle enterprise databases and for various reasons, we decided to build one in AWS for a new project.

As our preferred AWS provisioning tool is Terraform, I went looking for examples on how to do this in RDS – but found very very little.

Below is the result of what I cobbled together.  I’ll assume you know how to setup all the infrastructure it requires beforehand like subnet groups and KMS keys – but shout in the comments if anything’s unclear.

resource "aws_db_instance" "oracleRDS" { 
  engine                     = "oracle-ee" 
  engine_version             = "12.1" 
  instance_class             = "db.m3.medium" 
  storage_type               = "io1" 
  iops                       = 1000 
  allocated_storage          = 100 
  port                       = 1525 
  backup_retention_period    = 3 
  character_set_name         = "AL32UTF8" 
  db_subnet_group_name       = "${aws_db_subnet_group.rds_oracle.id}" 
  final_snapshot_identifier  = "awsdb-${var.env}-final-snapshot" 
  identifier                 = "awsdb-${var.env}" 
  storage_encrypted          = true 
  kms_key_id                 = "${aws_kms_key.rds_encryption_kms_key.arn}" 
  multi_az                   = true 
  username                   = "rdsmaster" 
  password                   = "${var.rds_oracle_password}" 
  skip_final_snapshot        = false 
  tags = { 
    Name = "awsdb-${var.env}" 
  } 
}

In a few days I’ll post how we then connect this RDS instance to the Database Migration Service (DMS).