hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.17k forks source link

[TechDebt]: `CheckFrameworkResourceDisappears` fails to handle non-string root arguments #35746

Open jar-b opened 8 months ago

jar-b commented 8 months ago

Description

When writing a _disappears tests for a framework resource, root elements that are not string types silently fail to copy into the underlying resource schema used to initiate the out-of-band resource destruction. This causes issues if a non-string attribute is required as an input for the delete operation.

The failure occurs here, where it is logged as a warning: https://github.com/hashicorp/terraform-provider-aws/blob/e9c3c952a6433442409b23ea33fd28055099198f/internal/acctest/framework.go#L42-L50

is.Attributes is a map[string]string so the value passed into the SetAttribute method (v) will always result in the underlying reflection attempting to convert a string. An example of the logged output for an argument of tftypes.Bool:

2024/02/09 15:06:46 [WARN] associate_entire_account(true): Value Conversion Error

An unexpected error was encountered trying to convert the Terraform value. This is always an error in the provider. Please report the following to the provider developer:

can't unmarshal tftypes.String into *bool, expected boolean
associate_entire_account

Ideally this function could be adjusted to safely handle root attributes of all types, not just strings.

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 8 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue