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

internal/framework/types: surface ARN validation errors #40008

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Nov 4, 2024

Description

Previously the ARNTypes ValueFromString method parsed the string value and set the value to Unknown in cases where validation failed. This caused a plan time failure indicating a difference between the planned value (unknown) and config value (known string). This obfuscated the underlying error which is actually an invalid ARN value.

Invalid ARNs provided in a configuration will now produce errors similar to the following:

│ Error: Invalid ARN Value
│
│   with aws_bedrockagent_agent.test,
│   on main.tf line 16, in resource "aws_bedrockagent_agent" "test":
│   16:   agent_resource_role_arn = "INVALID-ARN"
│
│ The provided value cannot be parsed as an ARN.
│
│ Path: agent_resource_role_arn
│ Value: INVALID-ARN
% go test ./internal/framework/types/...
ok      github.com/hashicorp/terraform-provider-aws/internal/framework/types    0.631s

Relations

Closes #39227

Copy link

github-actions bot commented Nov 4, 2024

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. labels Nov 4, 2024
Previously the `ARNType`s `ValueFromString` method parsed the string value and set the value to Unknown in cases where validation failed. This caused a plan time failure indicating a difference between the planned value (unknown) and config value (known string). This obfuscated the underlying error which is actually an invalid ARN value.

Invalid ARNs provided in a configuration will now produce errors similar
to the following:

```
│ Error: Invalid ARN Value
│
│   with aws_bedrockagent_agent.test,
│   on main.tf line 16, in resource "aws_bedrockagent_agent" "test":
│   16:   agent_resource_role_arn = "INVALID-ARN"
│
│ The provided value cannot be parsed as an ARN.
│
│ Path: agent_resource_role_arn
│ Value: INVALID-ARN
```
@jar-b jar-b marked this pull request as ready for review November 4, 2024 21:52
@jar-b jar-b requested a review from a team as a code owner November 4, 2024 21:52
Copy link
Contributor

@johnsonaj johnsonaj left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@jar-b jar-b merged commit cc68fac into main Nov 5, 2024
38 checks passed
@jar-b jar-b deleted the b-arn-type-validation branch November 5, 2024 14:13
@github-actions github-actions bot added this to the v5.75.0 milestone Nov 5, 2024
terraform-aws-provider bot pushed a commit that referenced this pull request Nov 5, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 11, 2024
Copy link

This functionality has been released in v5.75.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: arnType custom type implementation prevents validation to work properly
2 participants