Skip to content

Commit

Permalink
If auto_generate_backend_file is true (we are auto-generating bac…
Browse files Browse the repository at this point in the history
…kend files), remove `backend.tf.json` when executing `atmos terraform clean` command (#135)
  • Loading branch information
aknysh authored Apr 14, 2022
1 parent 6e7e88e commit f983bc7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/exec/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ func ExecuteTerraform(cmd *cobra.Command, args []string) error {
fmt.Println(fmt.Sprintf("Deleting terraform planfile: %s", planFile))
_ = os.Remove(path.Join(componentPath, planFile))

// If `auto_generate_backend_file` is `true` (we are auto-generating backend files), remove `backend.tf.json`
if c.Config.Components.Terraform.AutoGenerateBackendFile {
fmt.Println("Deleting 'backend.tf.json' file")
_ = os.Remove(path.Join(componentPath, "backend.tf.json"))
}

tfDataDir := os.Getenv("TF_DATA_DIR")
if len(tfDataDir) > 0 && tfDataDir != "." && tfDataDir != "/" && tfDataDir != "./" {
color.Cyan("Found ENV var TF_DATA_DIR=%s", tfDataDir)
Expand Down

0 comments on commit f983bc7

Please sign in to comment.