Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Too long identifier name error #226

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,24 @@ resource "random_pet" "instance" {
}
}

module "rds_identifier" {
count = local.enabled ? 1 : 0

source = "cloudposse/label/null"
version = "0.25.0"

name = random_pet.instance[0].id
# Max length of RDS identifier is 63 characters, but in `aws_rds_cluster_instance`
# we append the instance index to the identifier
# Setting the limit to 60 allow to use up to 99 instances, when only 16 is allowed
# (1 writer + 15 readers)
# https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Replication.html
id_length_limit = 60
}

resource "aws_rds_cluster_instance" "default" {
count = local.cluster_instance_count
identifier = "${random_pet.instance[0].id}-${count.index + 1}"
identifier = "${module.rds_identifier[0].id}-${count.index + 1}"
cluster_identifier = coalesce(join("", aws_rds_cluster.primary[*].id), join("", aws_rds_cluster.secondary[*].id))
instance_class = random_pet.instance[0].keepers.instance_class
db_subnet_group_name = join("", aws_db_subnet_group.default[*].name)
Expand Down