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

Conversation

MaxymVlasov
Copy link
Contributor

what

Fix too long identifier name without cluster recreation:

set id_length_limit = 40 for

module "aurora" {
  source  = "cloudposse/rds-cluster/aws"
  version = "1.10.0"
  ...
  id_length_limit = 40
}

will cause such recreation if final module.this.id will be between 40-60 characters

why

https://github.com/cloudposse/terraform-aws-rds-cluster/releases/tag/1.10.0 introduced random_pet, which adds 2 extra words on the top of module.this.id, and that exceed limit of 63 allowed characters for RDS names

╷
│ Error: creating RDS Cluster (company-staging-aurora-payments-ledger-service-aliases) Instance (company-staging-aurora-payments-ledger-service-aliases-promoted-piglet-1): operation error RDS: CreateDBInstance, https response error StatusCode: 400, RequestID: 1979b42f-b1df-4e00-b0ec-d3b629b3002d, api error InvalidParameterValue: Invalid database identifier:  company-staging-aurora-payments-ledger-service-aliases-promoted-piglet-1
│ 
│   with module.aurora_aliases.aws_rds_cluster_instance.default[0],
│   on .terraform/modules/aurora_aliases/main.tf line 261, in resource "aws_rds_cluster_instance" "default":261: resource "aws_rds_cluster_instance" "default" {

This PR limit final identifier to 62-63 chars (depends on count of replica)

references

Fixing #213

@MaxymVlasov MaxymVlasov requested review from a team as code owners August 22, 2024 12:11
@mergify mergify bot added the triage Needs triage label Aug 22, 2024
@kevcube
Copy link
Contributor

kevcube commented Aug 22, 2024

@MaxymVlasov we still want to retain that random_pet because when we create_before_destroy we need to have unique names for the new instances.

@MaxymVlasov
Copy link
Contributor Author

@kevcube
TL;DR: id_length_limit in cloudposse/label/null calculate md5() of full_id, crop full_id and attach md5 at the end.

So you still have unique id based on pet_random, but which not violate AWS limitation

https://github.com/cloudposse/terraform-null-label/blob/5c464f42c388deb18222c2285c9e450b1fc233c7/main.tf#L161-L166

main.tf Outdated Show resolved Hide resolved
kevcube
kevcube previously approved these changes Aug 22, 2024
Copy link
Contributor

@kevcube kevcube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, I only looked at the part where you replace random_pet with module.rds_identifier and I assumed that was an identifier that was already being created, now I see it is a new one. LGTM

@kevcube
Copy link
Contributor

kevcube commented Aug 22, 2024

/terratest

@mergify mergify bot removed the triage Needs triage label Aug 22, 2024
main.tf Outdated Show resolved Hide resolved
@kevcube
Copy link
Contributor

kevcube commented Aug 22, 2024

/terratest

@mergify mergify bot added triage Needs triage and removed triage Needs triage labels Aug 22, 2024
@MaxymVlasov
Copy link
Contributor Author

@kevcube tests passed

@kevcube kevcube added patch A minor, backward compatible change bugfix Change that restores intended behavior labels Aug 22, 2024
@kevcube
Copy link
Contributor

kevcube commented Aug 22, 2024

@kevcube tests passed

ok - one thing I'm wondering is how we release this, it feels like a fix, but also this will cause consumer's db instances to be recycled so maybe I release as a minor. Going to ask for backup.

@MaxymVlasov
Copy link
Contributor Author

It will affect only DBs with a random_pet.id length == 61 (>=62 will see the same error as in PR description)
I don't know, how many DBs have exactly this number, so yeah, second eyes could be helpful

@kevcube
Copy link
Contributor

kevcube commented Aug 22, 2024

It will affect only DBs with a random_pet.id length == 61 (>=62 will see the same error as in PR description) I don't know, how many DBs have exactly this number, so yeah, second eyes could be helpful

Ah I see, thanks for that info, I thought all identifiers would get the hash appended. In this case I feel safer merging it, I think it's a rare situation that someone has their instance name at the character limit, especially considering the random_pet adds some unpredictability to length.

@kevcube
Copy link
Contributor

kevcube commented Aug 22, 2024

Although I cannot merge because I was the last pusher and also only approver 🤡 whoops!

@MaxymVlasov

This comment was marked as resolved.

@kevcube
Copy link
Contributor

kevcube commented Aug 22, 2024

/terratest

@kevcube kevcube enabled auto-merge (squash) August 22, 2024 14:47
Copy link
Member

@aknysh aknysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @MaxymVlasov

@kevcube kevcube merged commit 1aa3450 into cloudposse:main Aug 22, 2024
107 checks passed
Copy link

These changes were released in v1.11.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Change that restores intended behavior patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants