terraform-plugin-sdk icon indicating copy to clipboard operation
terraform-plugin-sdk copied to clipboard

Allow running Check tests on imported resources

Open greentruff opened this issue 4 years ago • 0 comments

SDK version

v1.15.0

I checked 2.4.4 and the behavior for imported tests is identical, state is not modified.

Use-cases

The terraform plugin for datadog supports modifying certain properties of default rules. Default rules cannot be created by users and are instead a special resource which must be imported before being modified. See documentation the documentation here.

Implementation of the resource is here

We would like to implement tests which check that the fields are being modified correctly.

Attempted Solutions

The existing tests misused the test framework and use both ImportState: True and Check. The Checks are ignored in this case, testing with ImportStateCheck the state is right after import and does not take into account other changes on top of it. It is also not possible to split the check into multiple steps as ImportState will revert back to the previous state after an import step.

Proposal

Add a flag to keep state after an import step such as ImportPersistState: True which returns the updated state so that following steps can modify it.

References

greentruff avatar Mar 01 '21 18:03 greentruff