Skip to content

Commit

Permalink
Dev #6: adding environment argument
Browse files Browse the repository at this point in the history
  • Loading branch information
JimCircadian committed Feb 27, 2023
1 parent fa489eb commit bbd50b9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion setup_terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def main():
parser = argparse.ArgumentParser(
description="Initialise the Azure infrastructure needed by Terraform"
)
parser.add_argument(
"-e",
"--environment",
default="dev",
help="Environment name to create, will be used to identify ALL resources (make it short)"
)
parser.add_argument(
"-s",
"--azure-subscription-name",
Expand Down Expand Up @@ -95,6 +101,7 @@ def main():
subscription_id,
tenant_id,
storage_key,
args.environment
)


Expand Down Expand Up @@ -123,7 +130,7 @@ def get_azure_ids(credential, subscription_name):
return (subscription_id, tenant_id)


def write_terraform_configs(subscription_id, tenant_id, storage_key, **kwargs):
def write_terraform_configs(subscription_id, tenant_id, storage_key, environment, **kwargs):
"""Write Terraform config files"""
# Backend secrets
backend_secrets_path = os.path.join("terraform", "backend.secrets")
Expand All @@ -141,6 +148,7 @@ def write_terraform_configs(subscription_id, tenant_id, storage_key, **kwargs):
azure_vars = {
"subscription_id": subscription_id,
"tenant_id": tenant_id,
"environment": environment,
}
azure_vars.update(kwargs)
with open(azure_secrets_path, "w") as f_out:
Expand Down

0 comments on commit bbd50b9

Please sign in to comment.