Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/ops/terraform/terraform_cmd_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def generate(self, args):
else:
variables_file = ' '

auto_approve = '-auto-approve' if args.auto_approve else ''

if args.subcommand == 'plan':
generate_module_templates = True
terraform_refresh_command = ''
Expand Down Expand Up @@ -157,10 +159,6 @@ def generate(self, args):
# todo maybe this deserves a better implementation later
generate_module_templates = True

auto_approve = ''
if args.auto_approve:
auto_approve = '-auto-approve'

self.inventory_generator.clear_cache()
if args.skip_plan:
# Run Terraform apply without running a plan first
Expand Down Expand Up @@ -198,14 +196,15 @@ def generate(self, args):
"{terraform_init_command}" \
"terraform plan -destroy " \
"-refresh=true {vars} {variables_file} {state_argument} && " \
"terraform destroy {vars} {variables_file} {state_argument} -refresh=true".format(
"terraform destroy {vars} {variables_file} {state_argument} -refresh=true {auto_approve}".format(
root_dir=self.root_dir,
terraform_path=terraform_path,
variables_file=variables_file,
vars=vars,
state_argument=state_argument,
terraform_init_command=terraform_init_command,
remove_local_cache=remove_local_cache
remove_local_cache=remove_local_cache,
auto_approve=auto_approve
)
elif args.subcommand == 'output':
cmd = "cd {root_dir}/{terraform_path} && " \
Expand Down