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.
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.
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.
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 amap[string]string
so the value passed into theSetAttribute
method (v
) will always result in the underlying reflection attempting to convert a string. An example of the logged output for an argument oftftypes.Bool
: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