Skip to content

Commit

Permalink
Ignore missing paths during Read phase
Browse files Browse the repository at this point in the history
When the source directory can't be found during a Read, it isn't
meaningful to try to hash it and compare the hashes. Instead we should
mark it dirty and continue to the Create step, where we will load the
source templates based on the current module location instead of the
plan contents.

Fixes hashicorp#19
  • Loading branch information
weargoggles committed Apr 19, 2019
1 parent 5dea6ba commit 95c032c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions template/resource_template_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ func resourceTemplateDirRead(d *schema.ResourceData, meta interface{}) error {
return nil
}

// https://github.com/terraform-providers/terraform-provider-template/issues/19
// If we think we can't find the input, then either:
// a) it really isn't there
// b) the state contains a stale absolute path
// If the input really doesn't exist, we will still fail during the create.
// Mark the resource for creation without trying to checksum it.
if _, err := os.Stat(sourceDir); os.IsNotExist(err) {
d.SetId("")
return nil
}

// If the combined hash of the input and output directories is different from
// the stored one, mark the resource for re-creation.
//
Expand Down

0 comments on commit 95c032c

Please sign in to comment.