Skip to content

Commit

Permalink
remove terraform plan set use -auto-apply
Browse files Browse the repository at this point in the history
It is faster to use just auto apply then in two steps plan and apply.
Apply starts immediately after planning in auto apply. There are few
seconds of lag when we have two separate commands.
  • Loading branch information
ianic committed Dec 6, 2021
1 parent 2a6f645 commit a8c2c65
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions node/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ func (t *Terraform) initPlanApply(destroy bool) error {
if err := t.init(); err != nil {
return err
}
if err := t.plan(destroy); err != nil {
return err
}
if err := t.apply(destroy); err != nil {
return err
}
Expand All @@ -136,20 +133,11 @@ func (t *Terraform) init() error {
return nil
}

func (t *Terraform) plan(destroy bool) error {
args := []string{"terraform", "plan", "-no-color", "-input=false", "-out=tfplan", "-compact-warnings"}
if destroy {
args = append(args, "-destroy")
}
return t.shellExecDefault(args)
}

func (t *Terraform) apply(destroy bool) error {
args := []string{"terraform", "apply", "-no-color", "-input=false", "-compact-warnings"}
args := []string{"terraform", "apply", "-no-color", "-input=false", "-compact-warnings", "-auto-approve"}
if destroy {
args = append(args, "-destroy")
}
args = append(args, "tfplan")
opt := t.shellExecOpts(logPrefix, args)
opt.ErrorsMap = map[string]error{
"ConflictException: Unable to complete operation due to concurrent modification. Please try again later.": conflictException,
Expand Down

0 comments on commit a8c2c65

Please sign in to comment.