RDS: only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in “name”

Good evening, I’m having this problem.

And I can’t identify where the error is

Could anyone help me please.

    module.dbm_aurora_postgres.aws_rds_cluster_instance.this["2"]: Refreshing state... [id=dbm-aurora-postgres-2]
│ Error: only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in "name"
│   with module.dbm_aurora_mysql.aws_db_subnet_group.this[0],
│   on .terraform/modules/dbm_aurora_mysql/main.tf line 41, in resource "aws_db_subnet_group" "this":
│   41:   name        = var.name
odule "dbm_aurora_mysql" {
  source  = "terraform-aws-modules/rds-aurora/aws"

  engine          = "aurora-mysql"
  engine_version  = "8.0.28"
  username = "user"
  port     = "3306"

  iam_database_authentication_enabled = true

  monitoring_interval  = 10
  apply_immediately    = true
  skip_final_snapshot  = true

  db_parameter_group_name         = "aurora-mysql8.0.28"
  db_cluster_parameter_group_name = "aurora-mysql8.0.28"

  database_name                = "mysql"
  performance_insights_enabled = true

  vpc_id                = module.vpc.vpc_id
  subnets               = module.vpc.private_subnets
  create_security_group = true
  security_group_tags = {
    Environment = "prd"
    CreatedBy   = "terraform"
    Project = "dbm"
    Description = "security group for dbm-prd-mysql"
  deletion_protection = false
  enabled_cloudwatch_logs_exports = ["mysql"]

  tags = {
    Environment = "prd"
    CreatedBy   = "terraform"
    Project = "dbm"


resource "aws_db_subnet_group" "this" {
  count = var.create_cluster && var.db_subnet_group_name == "" ? 1 : 0

  name        = var.name
  description = "For Aurora cluster ${var.name}"
  subnet_ids  = var.subnets

  tags = merge(var.tags, {
    Name = local.name

Hi @andreluys01,

In the source code of that terraform-aws-modules/rds-aurora/aws module I see variable "name" defined like this:

variable "name" {
  description = "Name used across resources created"
  type        = string
  default     = ""

So if you don’t set name explicitly then the module will provide the empty string as the default value.

The validation rule for name in aws_db_subnet_group requires at least one character, so the empty string isn’t actually a valid value for this argument despite that module specifying it as a default value.

With all of this said then, I think the problem here is that you need to set a name argument inside your module "dbm_aurora_mysql" block in order for that module to generate a valid configuration for its resource "aws_db_subnet_group" "this".

It could also help to open a bug report in that module’s repository to suggest that the name variable be declared as required, since the underlying resource type seems to require it and therefore it doesn’t seem like it can ever work to leave it omitted.

Thanks a lot, I add var name :slight_smile: and fix the error

now i have a new error

could you help me understand this error please.