Skip to content

Commit

Permalink
Merge pull request #6176 from dimagi/ap/allow-destroy-for-backup-prod
Browse files Browse the repository at this point in the history
Allow terraform destroy for backup-production enviroment
  • Loading branch information
AmitPhulera authored Jan 5, 2024
2 parents a9e77ca + fc4f87f commit a6f769c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/commcare_cloud/commands/terraform/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class Terraform(CommandBase):
)

def run(self, args, unknown_args):
if 'destroy' in unknown_args:
environment = get_environment(args.env_name)
if 'destroy' in unknown_args and environment.name != 'backup-production':
puts(color_error("Refusing to run a terraform command containing the argument 'destroy'."))
puts(color_error("It's simply not worth the risk."))
exit(-1)

environment = get_environment(args.env_name)
run_dir = environment.paths.get_env_file_path('.generated-terraform')
modules_dir = os.path.join(TERRAFORM_DIR, 'modules')
modules_dest = os.path.join(run_dir, 'modules')
Expand Down Expand Up @@ -209,7 +209,7 @@ def compact_waf_regexes(patterns, compactible_affixes=None, max_length=200):
intermediate_compacted_regexes = [
f'{prefix}({regex}){suffix}'
for (prefix, suffix), patterns in patterns_grouped_by_affix.items()
for regex in compact_waf_regexes_simply(patterns, max_length=max_length-len(prefix + suffix) - 2)
for regex in compact_waf_regexes_simply(patterns, max_length=max_length - len(prefix + suffix) - 2)
] + compact_waf_regexes_simply(non_matching_patterns, max_length=max_length)
# sort compacted patterns shortest to longest
intermediate_compacted_regexes.sort(key=lambda r: len(r))
Expand Down

0 comments on commit a6f769c

Please sign in to comment.