Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Created September 26, 2016 05:26
Show Gist options
  • Save tkuchiki/2896cc733da44c96baf56f1346c21223 to your computer and use it in GitHub Desktop.
Save tkuchiki/2896cc733da44c96baf56f1346c21223 to your computer and use it in GitHub Desktop.
terraform で Amazon Aurora の master - slave 構成の DB を起動する
$ cat terraform.tf
resource "aws_rds_cluster" "test_db_cluster" {
    cluster_identifier      = "test-db"
    availability_zones      = ["ap-northeast-1a","ap-northeast-1c"]
    database_name           = "foobar"
    master_username         = "foobar"
    master_password         = "hogehoge"
    backup_retention_period = 35
    preferred_backup_window = "07:00-09:00"
    skip_final_snapshot     = true
    snapshot_identifier     = "manually-test-db-20160926-1124"
    db_subnet_group_name    = "test-db-subnet"
    vpc_security_group_ids  = ["sg-xxxxxxxx"]
}

resource "aws_rds_cluster_instance" "test-db" {
    cluster_identifier        = "${aws_rds_cluster.test_db_cluster.id}"
    identifier                = "test-db"
    instance_class            = "db.r3.large"
    publicly_accessible       = false
    db_subnet_group_name      = "test-db-subnet"
    # writer
    promotion_tier            = 0
    #monitoring_interval       = 1
    #monitoring_role_arn       = ""
}

resource "aws_rds_cluster_instance" "test-db-rr" {
    cluster_identifier        = "${aws_rds_cluster.test_db_cluster.id}"
    identifier                = "test-db-rr"
    instance_class            = "db.r3.large"
    publicly_accessible       = false
    db_subnet_group_name      = "test-db-subnet"
    promotion_tier            = 15
    #monitoring_interval       = 1
    #monitoring_role_arn       = ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment