hashicorp / hashicorp/terraform-plugin-sdk

Validate Data Sources Do Not Contain Importer Declarations

Open
#460 0 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

```
v1.12.0
```

### Use-cases

The `helper/schema.Resource` type is shared between managed resources and data sources via the `helper/schema.Provider` type `DataSourcesMap` and `ResourcesMap` fields. When its used
as a data source, it is extraneous/invalid for the `Importer` field to be declared since data sources inherently do not support import.

### Attempted Solutions

Manual pull request review comments.

### Proposal

Enhance the provider/resource validation (performed via provider unit testing) to check if `Importer` is declared for any data sources declared via `DataSourcesMap` and return a validation failure.

### References

- https://github.com/bflad/tfproviderlint/issues/172
- https://github.com/terraform-providers/terraform-provider-aws/pull/11965

Contributor guide

Open the contributing guide

Research direction

Start with the provider unit testing validation that examines DataSourcesMap and ResourcesMap, then trace how each data source's helper/schema.Resource is checked. Add coverage for a data source with Importer declared and make the validation return a failure; existing provider validation tests should confirm the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.