terraform-provider-cloudamqp
terraform-provider-cloudamqp copied to clipboard
Online validation of plan, region
Instead of hard coding all the plan names here:
https://github.com/cloudamqp/terraform-provider-cloudamqp/blob/8438a37fa5f61537936d3d338ad3df0476524133/cloudamqp/resource_cloudamqp_instance.go#L245-L256
Perhaps we can use the method outlined in https://github.com/hashicorp/terraform-plugin-sdk/issues/101#issuecomment-375809980 and use our API to validate the plan name.
Same goes for region, where we have no validation in the provider today, our API could be used to validate the given region.
Docs: https://pkg.go.dev/github.com/hashicorp/[email protected]/helper/customdiff
Tested to add online validation for region in our API backend. Made it reachable through go-api and passed along 'ApiBaseUrl'. Can be set similar to 'apikey' and 'baseurl' in the provider configuration.
customdiff.ValidateValue("region", func(value, meta interface{}) error {
api := meta.(*api.API)
result, err := api.ValidateRegion(ApiBaseUrl, value.(string))
if result {
return nil
}
return err
}),
Could be the way to go to move the validation to our backend instead.
Implemented in: https://github.com/cloudamqp/terraform-provider-cloudamqp/pull/201