I have a Terraform project which uses the MySQL provider. Because of the way Terraform works, the MySQL provider will fail to load correctly because the AWS_RDS instance doesn't exist. Is there a way for me to delay or split my project so that the MySQL provider doesn't load during the main "apply"?
I've examined workspaces, and I see that you can use a count to trigger a resource to load or not load based off of the workspace name. But that didn't work anyway I thought.
I've also seen this issue mentioned on the Hashicorp GitHub, but on one seems to be offering a workaround
Any help is greatly appreciated.
Here is a snippet of my data-storage configuration thus far:
resource "aws_db_subnet_group" "default" {
name = "${var.database_subnet_group_name}"
subnet_ids = ["${var.database_subnets}"]
tags {
Name = "${var.database_subnet_group_name}"
}
}
resource "aws_rds_cluster_instance" "cluster_instances" {
count = 1
identifier = "app-aurora-cluster-${count.index}"
cluster_identifier = "${aws_rds_cluster.some_cluster.id}"
instance_class = "db.t2.medium"
db_subnet_group_name = "${var.database_subnet_group_name}"
publicly_accessible = true
}
resource "aws_rds_cluster" "some_cluster" {
cluster_identifier = "app-aurora-cluster"
availability_zones = ["${var.database_azs}"]
database_name = "${var.database_name}"
db_subnet_group_name = "${var.database_subnet_group_name}"
master_username = "auroradmin"
master_password = "%XwPn}gU6sX<y8Wx"
skip_final_snapshot = true
vpc_security_group_ids = ["${var.database_security_groups}"]
}
/*
# This has to be commented out during the first pass
# because Terraform will try to connect to the
# MySQL Aurora server to refresh the state even
# though it currently doesn't exist.
# Configure the MySQL provider
provider "mysql" {
endpoint = "${aws_rds_cluster.some_cluster.endpoint}"
username = "auroradmin"
password = "%XwPn}gU6sX<y8Wx"
}