Skip to content

Commit

Permalink
Enhance terraform logging
Browse files Browse the repository at this point in the history
  • Loading branch information
christophetd committed Jan 19, 2022
1 parent 1c138c6 commit 0fc9613
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/stratus/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (m *Runner) CleanUp() error {

// Nuke pre-requisites
if m.Technique.PrerequisitesTerraformCode != nil {
log.Println("Cleaning up with terraform destroy")
log.Println("Cleaning up technique pre-requisites with terraform destroy")
prerequisitesCleanupErr = m.TerraformManager.TerraformDestroy(m.TerraformDir)
if prerequisitesCleanupErr != nil {
log.Println("Warning: unable to cleanup TTP pre-requisites: " + prerequisitesCleanupErr.Error())
Expand Down
5 changes: 2 additions & 3 deletions pkg/stratus/runner/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (m *TerraformManagerImpl) TerraformInitAndApply(directory string) (map[stri
terraform, err := tfexec.NewTerraform(directory, m.terraformBinaryPath)
terraformInitializedFile := path.Join(directory, ".terraform-initialized")
if !utils.FileExists(terraformInitializedFile) {
log.Println("Initializing Terraform")
log.Println("Initializing Terraform to spin up technique pre-requisites")
err = terraform.Init(context.Background())
if err != nil {
return nil, errors.New("unable to Initialize Terraform: " + err.Error())
Expand All @@ -70,7 +70,7 @@ func (m *TerraformManagerImpl) TerraformInitAndApply(directory string) (map[stri

}

log.Println("Applying Terraform")
log.Println("Applying Terraform to spin up technique pre-requisites")
err = terraform.Apply(context.Background(), tfexec.Refresh(false))
if err != nil {
return nil, errors.New("unable to apply Terraform: " + err.Error())
Expand All @@ -93,6 +93,5 @@ func (m *TerraformManagerImpl) TerraformDestroy(directory string) error {
return err
}

log.Println("Destroying Terraform")
return terraform.Destroy(context.Background())
}

0 comments on commit 0fc9613

Please sign in to comment.