terraform-plugin-framework icon indicating copy to clipboard operation
terraform-plugin-framework copied to clipboard

website: Mention id Attribute Addition/Requirement for SDKv2 Migration

Open bflad opened this issue 2 years ago • 0 comments

Module version

v1.4.2

Description

For developers migrating from SDKv2 to the framework and wanting to keep practitioner compatibility as much as possible, they must add the previously implicit id attribute to their framework schemas for data sources and resources. This should be done regardless that terraform-plugin-testing v1.5.0 no longer requires the id attribute in the testing code. The id attribute can generally be implemented as:

map[string]schema.Attribute{
  // ... other attributes ...
  "id": schema.StringAttribute{
    Computed: true,
    PlanModifiers: []planmodifier.String{
      stringplanmodifier.UseStateForUnknown(),
    },
  },
}

We should call this out somehow in the migration guide. While https://developer.hashicorp.com/terraform/plugin/framework/migrating/attributes-blocks/attribute-schema seems the "correct" place to put this, I'm not sure if it warrants additional placement/consideration since it may be harder to detect if the attribute wasn't previously acceptance tested.

bflad avatar Dec 19 '23 13:12 bflad