Skip to content

StateFunc cannot be used within a TypeSet in 0.12 #160

@jbardin

Description

@jbardin

If a provider is using Schema.StateFunc on an attribute of a set value, the resource will see extra entries in the set obtained from d.Get during Apply.

This is because the SDK is getting different values for the set between PlanResourceChange and ApplyResourceChange, and generating different hash values for the flatmap representation. This prevents the new protocol shims from being able to correlate the planned set values with the original config values, and they appear as separate set elements.

The recommended option here is to convert the TypeSet to a TypeList in the schema, which should behave the same in most respects, other than the inherent deduplication of identical config blocks which isn't usually a concern.

Migrating the state from the hashed value to the config value is a harder prospect, and will probably require manual intervention by the user, i.e. applying once without changing the config to save the new values.

This situation is not likely to have a remedy when using the legacy SDK with 0.12 or later, but I'm leaving the issue open here for provider developers that may encounter it during the upgrade process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsubsystem/typesIssues and feature requests related to the type system of Terraform and our shims around it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions