From 409c5359c5f5bf3742d440b56501f87a5387afcc Mon Sep 17 00:00:00 2001 From: Jacob McCann Date: Thu, 18 Feb 2016 18:09:23 -0600 Subject: [PATCH] Delete .terraform cache Terraform will pull and cache config. This causes issues if you try to change remotes as the cache will be pushed to your remote when it initializes the new remote. --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 12cfbab..181a5ee 100644 --- a/main.go +++ b/main.go @@ -38,12 +38,14 @@ func main() { commands = append(commands, installCaCert(vargs.Cacert)) } if remote.Backend != "" { + commands = append(commands, deleteCache()) commands = append(commands, remoteConfigCommand(remote)) } commands = append(commands, planCommand(vargs.Vars)) if !vargs.Plan { commands = append(commands, applyCommand()) } + commands = append(commands, deleteCache()) for _, c := range commands { c.Env = os.Environ() @@ -72,6 +74,14 @@ func installCaCert(cacert string) *exec.Cmd { ) } +func deleteCache() *exec.Cmd { + return exec.Command( + "rm", + "-rf", + ".terraform", + ) +} + func remoteConfigCommand(config remote) *exec.Cmd { args := []string{ "remote",