hashicorp / hashicorp/terraform-plugin-sdk

add a flag to determine whether `ReadContext` is called via `schema.ImportStatePassthroughContext`

Open
#1,005 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

### SDK version

```
github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0dk/...
```

### Use-cases

currently, there is no way to determine whether we are encountering an on-going import operation in `schema.Resource.ReadContext` if it is called via `schema.ImportStatePassthroughContext`

### Attempted Solutions

there is, currently, no clean solution to solve this

there is, however, a way to achieve it by implementing custom `schema.Resource.Importer.StateContext`, however we would like to be using `schema.ImportStatePassthroughContext`

### Proposal

add a method to `schema.ResourceData`, similar to `IsNewResource`, which would return `true` if there is an on-going import operation

Contributor guide

Open the contributing guide

Research direction

Start by tracing schema.ImportStatePassthroughContext into schema.Resource.ReadContext and inspect ResourceData methods such as IsNewResource. The change is complete when ResourceData exposes whether an import is ongoing and the behavior is covered by relevant SDK tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, terraform
Domain
backend-api-design, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.