Skip to content

Commit

Permalink
Use basenaame for plan file (#782)
Browse files Browse the repository at this point in the history
The terraform commands in that function are already running in the InputDir, so we don't need to specify the full path. Seems to not work sometimes.

Fixes #780
  • Loading branch information
MartinPetkov authored Feb 8, 2021
1 parent 2c8f716 commit f71d421
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/tfimport/tfimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"log"
"os"
"os/exec"
"path"
"regexp"
"strings"

Expand Down Expand Up @@ -576,11 +577,11 @@ func planAndImport(rn, importRn runner.Runner, runArgs *RunArgs) (retry bool, er
return false, fmt.Errorf("create temp file: %v", err)
}
defer os.Remove(tmpfile.Name())
planPath := tmpfile.Name()
if out, err := tfCmdOutput("plan", "-out", planPath); err != nil {
planName := path.Base(tmpfile.Name())
if out, err := tfCmdOutput("plan", "-out", planName); err != nil {
return false, fmt.Errorf("plan: %v\n%v", err, string(out))
}
b, err := tfCmdOutput("show", "-json", planPath)
b, err := tfCmdOutput("show", "-json", planName)
if err != nil {
return false, fmt.Errorf("show: %v\n%v", err, string(b))
}
Expand Down

0 comments on commit f71d421

Please sign in to comment.