From 898e67d4c374846553645d6a3258251af275cca6 Mon Sep 17 00:00:00 2001 From: Weiguang Date: Thu, 28 Jan 2021 15:48:10 +0800 Subject: [PATCH] fix: allow read permission error (#1) Allow read permission error on `local_file` to be regarded as a new resource creation. Related issue: --- internal/provider/resource_local_file.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/provider/resource_local_file.go b/internal/provider/resource_local_file.go index 5e0c0775..449036c6 100644 --- a/internal/provider/resource_local_file.go +++ b/internal/provider/resource_local_file.go @@ -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 }