Skip to content

Commit

Permalink
Backport #555
Browse files Browse the repository at this point in the history
Ignore data sources when verifying imported state.
  • Loading branch information
paddycarver committed Sep 3, 2020
1 parent 16d506c commit 44c4e42
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion helper/resource/testing_new_import_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ func testStepNewImportState(t *testing.T, c TestCase, wd *tftest.WorkingDir, ste
for _, r := range new {
// Find the existing resource
var oldR *terraform.ResourceState
for _, r2 := range old {
for r2Key, r2 := range old {
// Ensure that we do not match against data sources as they
// cannot be imported and are not what we want to verify.
// Mode is not present in ResourceState so we use the
// stringified ResourceStateKey for comparison.
if strings.HasPrefix(r2Key, "data.") {
continue
}

if r2.Primary != nil && r2.Primary.ID == r.Primary.ID && r2.Type == r.Type && r2.Provider == r.Provider {
oldR = r2
break
Expand Down

0 comments on commit 44c4e42

Please sign in to comment.