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]: route53profiles_association does not validate name #39793

Open
jandersen-plaid opened this issue Oct 18, 2024 · 2 comments · May be fixed by #39798
Open

[Bug]: route53profiles_association does not validate name #39793

jandersen-plaid opened this issue Oct 18, 2024 · 2 comments · May be fixed by #39798
Labels
bug Addresses a defect in current functionality. service/route53profiles Issues and PRs that pertain to the route53profiles service.

Comments

@jandersen-plaid
Copy link

Terraform Core Version

1.7.5

AWS Provider Version

5.72.1

Affected Resource(s)

  • aws_route53profiles_association

Expected Behavior

The name attribute should validate against a regex at plan time to prevent plans with unacceptable names from failing with a 400.

Actual Behavior

If you try to apply a plan with a name that does not match the regex of (?!^[0-9]+$)([a-zA-Z0-9\\-_' ']+) you will receive a 400 error.

For example, consider the resource:

 resource "aws_route53profiles_association" "testing" {
   name        = "testing.ue1"
   profile_id  = aws_route53profiles_profile.testing_test.id
   resource_id = aws_vpc.testing_ue1.id
 }

The plan for this resource succeeds, but on apply you will get:

aws_route53profiles_association.testing: Creating...
╷
│ Error: creating AWS Route 53 Profiles Association ("testing.ue1 Association"): operation error Route53Profiles: AssociateProfile, https response error StatusCode: 400, RequestID: --, ValidationException: 
│ 
│   with aws_route53profiles_association.testing,
│   on main.tf line 58, in resource "aws_route53profiles_association" "testing":
│   58: resource "aws_route53profiles_association" "testing" {
│ 
│ operation error Route53Profiles: AssociateProfile, https response error
│ StatusCode: 400, RequestID: --,
│ ValidationException: 
╵

Enabling debug logs reveals the cause:

$ TF_LOG=debug terraform apply
...
  http.response.body=
  | {"message":"1 validation error detected: Value 'testing.ue1' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: (?!^[0-9]+$)([a-zA-Z0-9\\-_' ']+)"}
...

This is unfortunately undocumented in all of the AWS docs I can find, but I will file a separate support ticket with AWS to get it documented.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_vpc" "testing_ue1" {
  cidr = "10.0.0.0/16"
}

resource "aws_route53profiles_profile" "testing_test" {
  name = "Testing Route53 Profile"
}

resource "aws_route53profiles_association" "testing" {
   name        = "testing.ue1"
   profile_id  = aws_route53profiles_profile.testing_test.id
   resource_id = aws_vpc.testing_ue1.id
}

Steps to Reproduce

To reproduce, attempt to apply the above Terraform.

Debug Output

I can post more if needed, but the only relevant output is:

  http.response.body=
  | {"message":"1 validation error detected: Value 'testing.ue1' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: (?!^[0-9]+$)([a-zA-Z0-9\\-_' ']+)"}

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

Yes

@jandersen-plaid jandersen-plaid added the bug Addresses a defect in current functionality. label Oct 18, 2024
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 service/route53profiles Issues and PRs that pertain to the route53profiles service. service/vpc Issues and PRs that pertain to the vpc service. needs-triage Waiting for first response or review from a maintainer. labels Oct 18, 2024
@jandersen-plaid
Copy link
Author

The tough part is going to be converting (?!^[0-9]+$)([a-zA-Z0-9\\-_' ']+) to a non-negative lookahead version of the regex. I don't think I am good enough at regex to do that, but I will try.

@ewbankkit ewbankkit removed needs-triage Waiting for first response or review from a maintainer. service/vpc Issues and PRs that pertain to the vpc service. labels Oct 18, 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/route53profiles Issues and PRs that pertain to the route53profiles service.
Projects
None yet
2 participants