Summary
Many REST APIs expose a dedicated validation endpoint (e.g. POST /resource/validate) that performs a dry-run check of a resource configuration without persisting anything. Today there is no way to call this during terraform plan — validation only surfaces at apply time when the API rejects the request.
Proposed solution
Add optional validate_path and validate_method attributes to the restapi_object resource. When set, the provider would call this endpoint during plan (via the ConfigValidators hook in the Terraform Plugin Framework) and fail the plan if the API returns a non-2xx response.
Example configuration:
resource "restapi_object" "example" {
path = "/resources"
data = jsonencode({ ... })
validate_path = "/resources/validate"
validate_method = "POST"
}
Implementation notes
The Terraform Plugin Framework already supports this via the resource.ResourceWithConfigValidators interface. The work would involve:
- Adding
validate_path / validate_method schema attributes to resource_api_object.go
- Implementing
ConfigValidators() returning a custom validator
- Adding a
ValidateObject() method to APIObject in apiclient/object.go mirroring the existing CreateObject() pattern
Happy to contribute a PR if there is interest.
Why this matters
Catching misconfigured resources at plan time rather than apply time:
- Prevents partial applies where unrelated resources succeed but the invalid one fails
- Gives faster feedback in CI pipelines
- Is especially valuable for complex resource configs where the API has richer validation logic than what can be expressed in Terraform schema
Summary
Many REST APIs expose a dedicated validation endpoint (e.g.
POST /resource/validate) that performs a dry-run check of a resource configuration without persisting anything. Today there is no way to call this duringterraform plan— validation only surfaces atapplytime when the API rejects the request.Proposed solution
Add optional
validate_pathandvalidate_methodattributes to therestapi_objectresource. When set, the provider would call this endpoint during plan (via theConfigValidatorshook in the Terraform Plugin Framework) and fail the plan if the API returns a non-2xx response.Example configuration:
Implementation notes
The Terraform Plugin Framework already supports this via the
resource.ResourceWithConfigValidatorsinterface. The work would involve:validate_path/validate_methodschema attributes toresource_api_object.goConfigValidators()returning a custom validatorValidateObject()method toAPIObjectinapiclient/object.gomirroring the existingCreateObject()patternHappy to contribute a PR if there is interest.
Why this matters
Catching misconfigured resources at plan time rather than apply time: