Skip to content

Instantly share code, notes, and snippets.

@Gunisalvo
Last active June 27, 2018 15:26
Show Gist options
  • Save Gunisalvo/14620bb204f0c13ad0eb99ef4d6c7c1f to your computer and use it in GitHub Desktop.
Save Gunisalvo/14620bb204f0c13ad0eb99ef4d6c7c1f to your computer and use it in GitHub Desktop.
UoL: Relational Data Base
variable "student_name" {
default = "STUDENT_NAME" #fix me!
}
variable "username" {}
variable "password" {}
variable "region" {
default = "us-east-2"
}
provider "aws" {
region = "${var.region}"
}
resource "aws_db_instance" "uol_main_db" {
name = "MySQL_CIT523_${var.student_name}"
identifier = "master"
allocated_storage = 10
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t2.micro"
backup_window = "09:46-10:16"
backup_retention_period = 3
username = "${var.username}"
password = "${var.password}"
skip_final_snapshot = false
final_snapshot_identifier = "${var.region}-final-snapshot-${md5(timestamp())}"
parameter_group_name = "default.mysql5.7"
}
resource "aws_db_instance" "uol_replica_db" {
name = "MySQL_CIT523_${var.student_name}_replica_01"
identifier = "replica"
replicate_source_db = "${aws_db_instance.uol_main_db.identifier}"
allocated_storage = 10
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t2.micro"
username = "${var.username}"
password = "${var.password}"
parameter_group_name = "default.mysql5.7"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment