hashicorp / hashicorp/terraform-plugin-sdk

Consider Generic Read/Write Support for Private State Data

Open
#836 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement proposal terraform-plugin-framework
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

SDK version
v2.10.1
Use-cases

This issue is a placeholder until more investigation and details can be added.

Providers may wish to use the available private state storage that is available for resources, which is outside Terraform CLI's drift detection handling. These values may not be significant to use as configuration elsewhere or to output for practitioner consumption.

Example use cases (if you are reading this and have others, please comment):

  • Required ETag for next API request
  • Prevent update/destroy configuration
  • Ignore/demote to warning validation configuration

This framework already has this storage plumbed through to helper/schema.ResourceData.meta, which is a map[string]interface{}, it is just not exposed for providers to read or write.

There are some things that must be accounted for:

  • Providers must not be able to overwrite the schema_version or helper/schema.TimeoutKey keys.
  • Providers must not be able to write non-UTF-8 data.
  • Providers must not be able to write more data than the gRPC limit.
  • Provider developers will need to be able to troubleshoot this data handling, since it is outside Terraform's user interface.
Attempted Solutions

Using Computed attributes, for which there is no mechanism to hide value drift detection.

Proposal

To be filled in more, but a quick sketch may be to add two methods to ResourceData:

func (d *ResourceData) GetPrivate(ctx context.Context, key string) (interface{}, diag.Diagnostics) {}

func (d *ResourceData) SetPrivate(ctx context.Context, key string, value interface{}) diag.Diagnostics {}
References

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by investigating how private state is currently stored in helper/schema.ResourceData.meta and how the linked framework issue approaches generic read/write support. Define the provider-facing API and validate the listed constraints: protected keys, UTF-8 data, gRPC size limits, and troubleshooting outside Terraform's user interface. Done means the proposal is detailed enough to implement and review.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, grpc
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.