variable env {}
variable master_username {}
variable master_password {}

provider "aws" {
  region = "us-east-1"
}

# Terraform backends cannot contain interpolations
terraform {
  backend "s3" {
    bucket         = "orcd-terraform-state"
    key            = "prod/phonofile-rds/terraform.tfstate"
    region         = "us-east-1"
    encrypt        = "true"
  }
}

module "rds" {
  source = "git@github.com:theorchard/terraform-rds//"

  environment                               = "${var.env}"
  rds_engine                                = "aurora-postgresql"
  rds_engine_version                        = "9.6.8" 
  service_name                              = "phonofile01"
  rds_db_subnet_group_name                  = "vpc-orchard"
  rds_cluster_instance_parameter_group_name = "default.aurora-postgresql9.6"
  rds_db_cluster_parameter_group_name       = "default.aurora-postgresql9.6"
  rds_cluster_instance_class                = "db.r4.large"
  rds_vpc_security_group_ids                = ["sg-21f1ed44"]
  rds_cluster_instance_count                = "1"
  rds_master_username                       = "${var.master_username}"
  rds_master_password                       = "${var.master_password}"
}

module "rds_updates" {
  source = "git@github.com:theorchard/terraform-rds//"

  environment                               = "${var.env}"
  rds_engine                                = "aurora-postgresql"
  rds_engine_version                        = "9.6.8" 
  service_name                              = "phonofile02"
  rds_db_subnet_group_name                  = "vpc-orchard"
  rds_cluster_instance_parameter_group_name = "default.aurora-postgresql9.6"
  rds_db_cluster_parameter_group_name       = "default.aurora-postgresql9.6"
  rds_cluster_instance_class                = "db.r4.large"
  rds_vpc_security_group_ids                = ["sg-21f1ed44"]
  rds_cluster_instance_count                = "1"
  rds_master_username                       = "${var.master_username}"
  rds_master_password                       = "${var.master_password}"
}
