terraform-provider-cloudamqp icon indicating copy to clipboard operation
terraform-provider-cloudamqp copied to clipboard

Online validation of plan, region

Open dentarg opened this issue 3 years ago • 1 comments

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.

dentarg avatar Sep 27 '21 09:09 dentarg

Docs: https://pkg.go.dev/github.com/hashicorp/[email protected]/helper/customdiff

dentarg avatar Oct 19 '22 12:10 dentarg

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.

tbroden84 avatar Jan 17 '23 12:01 tbroden84

Implemented in: https://github.com/cloudamqp/terraform-provider-cloudamqp/pull/201

tbroden84 avatar May 05 '23 08:05 tbroden84