diff --git a/bundle/deploy/terraform/pkg.go b/bundle/deploy/terraform/pkg.go index 5e3807be..2d9293d1 100644 --- a/bundle/deploy/terraform/pkg.go +++ b/bundle/deploy/terraform/pkg.go @@ -1,3 +1,4 @@ package terraform const TerraformStateFileName = "terraform.tfstate" +const TerraformConfigFileName = "bundle.tf.json" diff --git a/bundle/deploy/terraform/write.go b/bundle/deploy/terraform/write.go index 3ec1b581..e688f6a6 100644 --- a/bundle/deploy/terraform/write.go +++ b/bundle/deploy/terraform/write.go @@ -32,7 +32,7 @@ func (w *write) Apply(ctx context.Context, b *bundle.Bundle) error { return err } - f, err := os.Create(filepath.Join(dir, "bundle.tf.json")) + f, err := os.Create(filepath.Join(dir, TerraformConfigFileName)) if err != nil { return err } diff --git a/cmd/bundle/summary.go b/cmd/bundle/summary.go index 596f7d3d..44c79f5d 100644 --- a/cmd/bundle/summary.go +++ b/cmd/bundle/summary.go @@ -42,11 +42,16 @@ func newSummaryCommand() *cobra.Command { if err != nil { return err } - _, err = os.Stat(filepath.Join(cacheDir, terraform.TerraformStateFileName)) - noCache := errors.Is(err, os.ErrNotExist) + _, stateFileErr := os.Stat(filepath.Join(cacheDir, terraform.TerraformStateFileName)) + _, configFileErr := os.Stat(filepath.Join(cacheDir, terraform.TerraformConfigFileName)) + noCache := errors.Is(stateFileErr, os.ErrNotExist) || errors.Is(configFileErr, os.ErrNotExist) if forcePull || noCache { - err = bundle.Apply(cmd.Context(), b, terraform.StatePull()) + err = bundle.Apply(cmd.Context(), b, bundle.Seq( + terraform.StatePull(), + terraform.Interpolate(), + terraform.Write(), + )) if err != nil { return err }