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
Open
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
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

resource "random_id" "salt" {
Expand Down