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 #46 - character point in VPC name #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gbloquel
Copy link

Fix the issue #46

Copy link

@tymik tymik left a comment

Choose a reason for hiding this comment

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

I recommend verifying if the proposed change affects other resources.
In this case, the vpc_name local is used to substitute also descriptions.
When it is modified globally before, you will eventually finish with descriptions mentioning improper VPC names and that can lead to unnecessary confusions.

I know it may seem minor, but imagine a case when a newly hired engineer starts working with an infrastructure and the resource's description points them to different VPC.
If the VPC doesn't exist, it is confusing what is going on.
If both - dotted any hyphened VPCs exist - they would be confused even more.

@@ -3,7 +3,7 @@ data "aws_vpc" "vpc" {
}

locals {
vpc_name = lookup(data.aws_vpc.vpc.tags, "Name", var.vpc_id)
vpc_name = replace(lookup(data.aws_vpc.vpc.tags, "Name", var.vpc_id), ".", "-")
Copy link

Choose a reason for hiding this comment

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

I would suggest adding a separate local and perform the replace for that local, then use the new local in L46:

  name = replace(format("%.255s", lower(replace("tf-redis-${var.name}-${var.env}-${local.vpc_name}-${random_id.salt.hex}", "_", "-"))), "/\\s/", "-")

as vpc_name is used for other parts and such change would make the descriptions unclear.

And maybe the replace would be honestly better directly in the name, like:

name = replace(format("%.255s", lower(replace("tf-redis-${var.name}-${var.env}-replace(${local.vpc_name}, ".", "-")-${random_id.salt.hex}", "_", "-"))), "/\\s/", "-")

or some sort of combination, it is worth to play up a bit with it.

Copy link

Choose a reason for hiding this comment

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

note: I haven't tested that my proposal is syntactically correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants