From bbd50b9a1f0feb5ae71fb6a88940614efc2901de Mon Sep 17 00:00:00 2001 From: James Byrne Date: Mon, 27 Feb 2023 10:50:30 +0000 Subject: [PATCH] Dev #6: adding environment argument --- setup_terraform.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/setup_terraform.py b/setup_terraform.py index 071eedf..86ef0f2 100755 --- a/setup_terraform.py +++ b/setup_terraform.py @@ -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", @@ -95,6 +101,7 @@ def main(): subscription_id, tenant_id, storage_key, + args.environment ) @@ -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") @@ -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: