Plan Modification
Custom Attribute Plan Modification
Attribute plan modifiers enable advanced default value, resource replacement, and difference suppression logic in managed resources. Due to the Terraform SDK implementation, attribute-level plan modifiers do not have access to provider-level configuration or the API client, however that SDK does support custom resource-level plan modification with implementing the resource.ResourceWithModifyPlan
interface.
Use the x-speakeasy-plan-modifiers
extension to add custom attribute-level plan modification logic to Terraform plan operations.
In this scenario, when Speakeasy next generates the Terraform provider, it will bootstrap a custom plan modifier file, located at internal/planmodifiers/int64planmodifier/age_modifier.go
, and import the schema configuration wherever x-speakeasy-plan-modifiers: AgeModifier
is referenced.
The x-speakeasy-plan-modifiers
extension supports an array of names as well, such as:
Implementation Notes
Implementation notes
A plan modifier is a type that implements the plan modifier interface defined by the terraform-plugin-framework
. A unique plan modifier is bootstrapped in the appropriate subfolder for the Terraform type that it is applied to, which is usually one of the following:
boolplanmodifiers
float64planmodifiers
int64planmodifiers
listplanmodifiers
mapplanmodifiers
numberplanmodifiers
objectplanmodifiers
setplanmodifiers
stringplanmodifiers
-
A modifier can only be applied to a resource attribute. The annotation will be ignored for data sources. Modifiers cannot be applied at the same level as the
x-speakeasy-entity
annotation because that becomes the “root” of the Terraform resource. -
Speakeasy regenerations do not delete user-written code. If the modifier is no longer in use, it will be ignored (no longer referenced) but the source file will remain. You might want to delete such an orphaned modifier file for repository hygiene.
Last updated on