The detailed error is:
Error: only lowercase alphanumeric characters and hyphens allowed in "cluster_identifier"
on ../rds_cluster/main.tf line 6, in resource "aws_rds_cluster" "mysql-cluster":
6: cluster_identifier = var.identifier
I get the above error while creating a rds_cluster from terraform. My main.tf file has the below code:
provider "aws"{
region = var.region
}
resource "aws_rds_cluster" "mysql-cluster" {
cluster_identifier = var.identifier
availability_zones = var.azs
database_name = var.db_name
master_username = var.username
master_password = var.password
}
The variable.tf file is:
variable "region"{
default = "us-east-1"
}
variable "identifier" {
default = "aurora-cluster"
}
variable "db_name" {
default = "mydb"
}
variable "username" {}
variable "password" {}
variable "azs" {}
And the module file that is calling this "rds_cluster" is:
provider "aws"{
region = "us-east-1"
}
data "aws_availability_zones" "azs" {
}
data "aws_secretsmanager_secret_version" "creds" {
secret_id = "db-creds"
}
module "mysql_aurora_instances" {
source = "../rds_instance/"
my_count = 2
identifier = "aurora-cluster"
cluster_identifier = "mysql_aurora_cluster"
instance_class = "db.t2.micro"
engine = "aurora-mysql"
engine_version = "5.7"
}
module "mysql_aurora_cluster" {
source = "../rds_cluster/"
identifier = "mysql_aurora_cluster"
azs = data.aws_availability_zones.azs.names
db_name = "my_db"
username = "demo"
password = data.aws_secretsmanager_secret_version.creds.secret_id
}
Points to note:
- I am using terraform 0.14
- When I perform terraform validate I get "Success! The configuration is valid."
- However, when I perform terraform plan, I get the above error