Skip to content

Commit

Permalink
fix: allow read permission error (#1)
Browse files Browse the repository at this point in the history
Allow read permission error on `local_file` to be
regarded as a new resource creation.

Related issue:
<hashicorp#55>
  • Loading branch information
guangie88 committed Jan 28, 2021
1 parent 6f9c1a9 commit 898e67d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/provider/resource_local_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ func resourceLocalFile() *schema.Resource {
}

func resourceLocalFileRead(d *schema.ResourceData, _ interface{}) error {
// If the output file doesn't exist, mark the resource for creation.
// If the output file doesn't exist or cannot be read due to permission
// issues, mark the resource for creation.
outputPath := d.Get("filename").(string)
if _, err := os.Stat(outputPath); os.IsNotExist(err) {
if _, err := os.Stat(outputPath); os.IsNotExist(err) || os.IsPermission(err) {
d.SetId("")
return nil
}
Expand Down

0 comments on commit 898e67d

Please sign in to comment.