Unable to create global database using Terraform

175 views
Skip to first unread message

jroy

unread,
Dec 31, 2018, 7:09:33 AM12/31/18
to Terraform
I am trying to create an Aurora MySQL database using the following module-

resource "aws_rds_global_cluster" "rdsglobal" {
  provider                  = "aws.primary"
  
  global_cluster_identifier = "${var.global_database_id}"
  storage_encrypted         = "${var.storage_encrypted}"
}

resource "aws_rds_cluster_instance" "primary" {
  provider                  = "aws.primary"
  count                     = "${var.instance_count}"
  identifier                = "${var.db_name}-${count.index+1}"
  cluster_identifier        = "${aws_rds_cluster.primary.id}"
  instance_class            = "${var.instance_class}"
  engine                    = "${var.engine}"
  engine_version            = "${var.engine_version}"
  publicly_accessible       = "${var.publicly_accessible}"

}

resource "aws_rds_cluster" "primary" {
  provider                  = "aws.primary"
  cluster_identifier        = "${var.primary_cluster_id}"
  database_name             = "${var.db_name}"
  port                      = "${var.port}"
  engine                    = "${var.engine}"
  engine_version            = "${var.engine_version}"
  master_username           = "${var.master_username}"
  master_password           = "${random_string.password.result}"
  vpc_security_group_ids    = ["${var.security_group_ids}"] 
  db_subnet_group_name      = "${var.db_subnet_group_name}" 
  storage_encrypted         = "${var.storage_encrypted}"
  backup_retention_period   = "${var.backup_retention_period}"
  skip_final_snapshot       = "${var.skip_final_snapshot}"
  engine_mode               = "${var.engine_mode}"
  global_cluster_identifier = "${aws_rds_global_cluster.rdsglobal.id}"

}


resource "aws_rds_cluster_instance" "secondary" {
  provider                  = "aws.secondary"
  count                     = "${var.instance_count}"
  identifier                = "${var.db_name}-${count.index+1}"
  cluster_identifier        = "${aws_rds_cluster.secondary.id}"
  instance_class            = "${var.instance_class}"
  engine                    = "${var.engine}"
  engine_version            = "${var.engine_version}"
  publicly_accessible       = "${var.publicly_accessible}"

}

resource "aws_rds_cluster" "secondary" {
  depends_on                = ["aws_rds_cluster_instance.primary"]
  provider                  = "aws.secondary"
  cluster_identifier        = "${var.secondary_cluster_id}"
  port                      = "${var.port}"
  engine                    = "${var.engine}"
  engine_version            = "${var.engine_version}"
  master_username           = "${var.master_username}"
  master_password           = "${random_string.password.result}"
  vpc_security_group_ids    = ["${var.secondary_security_group_ids}"] 
  db_subnet_group_name      = "${var.db_subnet_group_name}" 
  engine_mode               = "${var.engine_mode}"
  global_cluster_identifier = "${aws_rds_global_cluster.rdsglobal.id}"

}



The primary cluster gets created but the secondary cluster throws the following error-

Error: Error applying plan:

1 error(s) occurred:

* aws_rds_cluster.secondary: 1 error(s) occurred:

* aws_rds_cluster.secondary: error creating RDS cluster: InvalidParameterCombination: Cannot specify user name for cross region replication cluster
status code: 400, request id: 10b82a78-898c-49e6-b28f-0a318fdc226f



I tried by removing the following line- 
master_username           = "${var.master_username}"


I got the below error-

Error: Error applying plan:

1 error(s) occurred:

* aws_rds_cluster.secondary: 1 error(s) occurred:

* aws_rds_cluster.secondary: provider.aws: aws_rds_cluster: : "master_username": required field is not set


Any help will be greatly appreciated.

Thanks!

brad.cu...@sendgrid.com

unread,
Jan 23, 2019, 4:49:50 PM1/23/19
to Terraform
I've fixed this in https://github.com/terraform-providers/terraform-provider-aws/pull/7213 but it is not reviewed or merged.

Brad
Reply all
Reply to author
Forward
0 new messages