Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

metal_project payment_method_id UUID validation prevents refresh #201

Closed
displague opened this issue Nov 21, 2021 · 3 comments · Fixed by #204
Closed

metal_project payment_method_id UUID validation prevents refresh #201

displague opened this issue Nov 21, 2021 · 3 comments · Fixed by #204

Comments

@displague
Copy link
Member

It is possible for the payment_method to not be included in the project API response, even when payment_method is included. This is due to some billing relationship or token access to billing information.

When payment info is not included in the API response, the PaymentMethod object has zero values, including the Href and ID. This results in UUID validation by Terraform.

During refresh:

invalid value for payment_method_id (must be a valid UUID)

Packngo should reflect that Project PaymentMethod can be null. (it may be omitted by the API)
Terraform validation should allow this field to be empty.
https://github.com/equinix/terraform-provider-metal/blob/main/metal/resource_metal_project.go#L59

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist. Note: the debug log will contain your API key, please review the log and delete sensitive secrets before submitting.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened?

Actual Behavior

What actually happened?

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

  • #1234
@displague
Copy link
Member Author

displague commented Nov 24, 2021

hashicorp/terraform-provider-aws#13943 offers a validation path using validation.Any and validation.ExactlyOneOf (which does not seem to be defined)

@t0mk
Copy link
Contributor

t0mk commented Nov 25, 2021

@displague I didn't manage to invoke the error but I think I see the problem. The PaymentMethod field is not a pointer so it's filled with empty struct on API response deserialization.

I guess we will need to do sth like

if len(proj.PaymentMethod.URL) != 0 
  d.Set("payment_method_id", path.Base(proj.PaymentMethod.URL))
}

... i.e. skip the assignment to the provider attribute unless the payment method URL is set. If it's not set, I think the format check won't trigger. I can't test it, the acceptance test doesn't seem to run the ValidateFunc if I assign empty string to the payment_method_id attribute.

@displague
Copy link
Member Author

Fix released in v3.2.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants