-
Notifications
You must be signed in to change notification settings - Fork 1.5k
data/aws/vpc: Sanitize cluster name for aws_lb and aws_lb_target_group #1089
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
Conversation
data/data/aws/vpc/common.tf
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this variable something else, like lb_base_name? Having a variable with the same name in var and local and using them both in places makes it difficult to know which one is the right one to use where.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this variable something else, like
lb_base_name?
Done with 0615c32 -> 7c3a98b.
For folks who use multi-component cluster names like jliu-beta1.test20190117, this change avoids raising errors like [1]: ERROR Error: module.vpc.aws_lb.api_external: only alphanumeric characters and hyphens allowed in "name": "jliu-beta1.test20190117-ext" ERROR ERROR Error: module.vpc.aws_lb.api_internal: only alphanumeric characters and hyphens allowed in "name": "jliu-beta1.test20190117-int" ERROR ERROR Error: module.vpc.aws_lb_target_group.api_external: only alphanumeric characters and hyphens allowed in "name" ERROR ERROR Error: module.vpc.aws_lb_target_group.api_internal: only alphanumeric characters and hyphens allowed in "name" ERROR ERROR Error: module.vpc.aws_lb_target_group.services: only alphanumeric characters and hyphens allowed in "name" I'm using HCL's replace function [2] with a regular expression to replace everything except the characters the error message claims are supported. I've allowed both upper and lower case, because [3] has: A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-), and period (.). Note that periods are only allowed when they serve to delimit components of "domain style names". (See RFC-921, "Domain Name System Implementation Schedule", for background). No blank or space characters are permitted as part of a name. No distinction is made between upper and lower case. But I haven't checked IsDNS1123Subdomain to see how it handles case. [1]: https://bugzilla.redhat.com/show_bug.cgi?id=1666956#c0 [2]: https://www.terraform.io/docs/configuration/interpolation.html#replace-string-search-replace- [3]: https://tools.ietf.org/html/rfc952
0615c32 to
7c3a98b
Compare
|
@wking: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
|
||
| // Only reference data sources which are gauranteed to exist at any time (above) in this locals{} block | ||
| locals { | ||
| lb_base_name = "${replace(var.cluster_name, "/[^A-Za-z0-9-]/", "-")}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is that last hyphen in the regex necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. As it stands, it is "replace all but {legal chars, including hyphens} with hyphens". Without the trailing -, it wold be replacing the input - with -. You'd want the trailing - if the replacement was an empty string, etc. Did you want me to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, duh. Ignore me.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: crawford, wking The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
we depend on predictive nature of some AWS resources, like IAM roles, subnets. SO rather than doing this for LB in terraform, Can we do this in Go? Maybe create a sanitized cluster-name that we can use in all our resources that we think are sensitive to these kind of things.. |
Can we punt on that until we need Go to reference a sanitized name? |
IMO i don't want any new addition to terraform codebase wrt changes like sanitization... but i'm okay punting if others think we can fix it later, no strong opinions ;) |
Cheap compromise would be dropping cluster-name from those entries like we did for buckets in #489 ;). My issue with plumbing back into Go before we have a consumer is that I don't know how far back to take it. Just to Personally, I don't see a lot of maintenance space between |
|
@wking: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
For folks who use multi-component cluster names like
jliu-beta1.test20190117, this change avoids raising errors like:I'm using HCL's
replacefunction with a regular expression to replace everything except the characters the error message claims are supported. I've allowed both upper and lower case, because RFC 952 has:But I haven't checked
IsDNS1123Subdomainto see how it handles case.