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

[Bug]: aws_lb_target_group name_prefix validation #27556

Open
nozo-moto opened this issue Oct 31, 2022 · 2 comments
Open

[Bug]: aws_lb_target_group name_prefix validation #27556

nozo-moto opened this issue Oct 31, 2022 · 2 comments
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@nozo-moto
Copy link

Terraform Core Version

1.3.3

AWS Provider Version

4.37.0

Affected Resource(s)

  • name_prefix of aws_lb_target_group's ValidateFunc.

Expected Behavior

This validation should Ignore variables or consider expansion.

Actual Behavior

This validation is return invalid even if name_prefix has variable.
And If value length exceeded 6, it return invalid.

validation code.

func validTargetGroupNamePrefix(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
prefixMaxLength := 32 - resource.UniqueIDSuffixLength
if len(value) > prefixMaxLength {
errors = append(errors, fmt.Errorf(
"%q cannot be longer than %d characters", k, prefixMaxLength))
}
if !regexp.MustCompile(`^[0-9A-Za-z-]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"only alphanumeric characters and hyphens allowed in %q", k))
}
if regexp.MustCompile(`^-`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q cannot begin with a hyphen", k))
}
return
}

"name_prefix": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ConflictsWith: []string{"name"},
ValidateFunc: validTargetGroupNamePrefix,
},

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

provider "aws" {}
resource "aws_alb_target_group" "tg" {
  count       = 5
  name_prefix = "tg-${count.index + 1}"
  port        = "80"
  protocol    = "HTTP"
  vpc_id   = aws_vpc.main.id
}

Steps to Reproduce

terraform validate

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No response

@nozo-moto nozo-moto added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Oct 31, 2022
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/elbv2 Issues and PRs that pertain to the elbv2 service. label Oct 31, 2022
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Nov 1, 2022
Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

No branches or pull requests

2 participants