hashicorp / hashicorp/terraform-plugin-testing

Allow overriding/specifying Resource Identity values in Import checks

Open
#667 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
68
Forks
22
Avg merge
2d 12h
Merged PRs (30d)
1

Description

### terraform-plugin-testing version

```
github.com/hashicorp/terraform-plugin-testing v1.16.0
```

### Use cases

In some cases, importing should allow un-normalized values in a Resource Identity attribute while the RI itself would have a normalized value.

For example, in `aws_route53_record`, the `name` attribute for the resource can be subdomain-only or a fully-qualified domain name with or without trailing dot. When using an `import` block, the `name` in the Resource Identity should also support these forms.

Currently, testing `resource.ImportBlockWithResourceIdentity` directly uses the Resource Identity from the resource. It is not possible to test the other forms.

### Proposal

A mechanism similar to the existing `ImportStateIdFunc` could be used to specify a value for the Resource Identity. Some option to modify the existing Resource Identity would be useful, especially if some of the identifying attributes are `Computed`-only.

For example, for `aws_route53_record`, there are four attributes `zone_id`, `name`, `type`, and `set_identifier`. We would want to use the existing `zone_id`, `type`, and `set_identifier`, but be able to de-normalize the `name`. `zone_id` is a `Computed`-only attribute on the Record's parent resource.

Contributor guide

Open the contributing guide

Research direction

Start by reading resource.ImportBlockWithResourceIdentity and the existing ImportStateIdFunc mechanism. Trace how Resource Identity values are obtained, including Computed-only attributes, and determine the API shape needed to override selected values. Done means import checks can exercise alternate, un-normalized identity values while preserving the other identity attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.