88import boto3
99
1010SUPPORTED_REGIONS = []
11- def init ():
11+ def init () -> None :
1212 """Performs an init on the terraform project
1313 """
1414 subprocess .run (f"terraform init -backend-config=backend.tfvars" , check = True , shell = True ) # nosec B602
1515
16- def set_supported_region ():
16+ def set_supported_region () -> None :
1717 """Sets The supported regions from parameter store
1818 """
1919 global SUPPORTED_REGIONS
@@ -43,7 +43,7 @@ def set_supported_region():
4343 SUPPORTED_REGIONS .remove (home_region )
4444 SUPPORTED_REGIONS .insert (0 , home_region )
4545
46- def get_audit_account ():
46+ def get_audit_account () -> str :
4747 """Get audit account from AWS Organization
4848
4949 Returns:
@@ -60,7 +60,7 @@ def get_audit_account():
6060
6161 return audit_account
6262
63- def get_accounts ():
63+ def get_accounts () -> list :
6464 """Get all accounts from AWS Organization
6565
6666 Returns:
@@ -84,7 +84,7 @@ def get_accounts():
8484
8585 return accounts
8686
87- def workspace_exists (account , region ) :
87+ def workspace_exists (account : str , region : str ) -> bool :
8888 """Checks to see if workspace already exists for current terraform project
8989
9090 Args:
@@ -97,7 +97,7 @@ def workspace_exists(account, region):
9797 completed_process = subprocess .run (f"terraform workspace list | grep { account } -{ region } " , shell = True ) # nosec B602
9898 return completed_process .returncode == 0
9999
100- def create_workspace (account , region ) :
100+ def create_workspace (account : str , region : str ) -> None :
101101 """Create new workspace for terraform and saves it into statefile
102102
103103 Args:
@@ -106,7 +106,7 @@ def create_workspace(account, region):
106106 """
107107 subprocess .run (f"terraform workspace new { account } -{ region } " , check = True , shell = True ) # nosec B602
108108
109- def switch_to_workspace (account , region ) :
109+ def switch_to_workspace (account : str , region : str ) -> None :
110110 """Switch to a created workspace in Terraform
111111
112112 Args:
@@ -115,7 +115,7 @@ def switch_to_workspace(account, region):
115115 """
116116 subprocess .run (f"terraform workspace select { account } -{ region } " , check = True , shell = True ) # nosec B602
117117
118- def plan (account , region ) :
118+ def plan (account : str , region : str ) -> None :
119119 """Performs a terraform plan operation on all stacks
120120
121121 Args:
@@ -124,7 +124,7 @@ def plan(account, region):
124124 """
125125 subprocess .run (f"terraform plan -var-file=config.tfvars -var account_id={ account } -var account_region={ region } " , check = True , shell = True ) # nosec B602
126126
127- def apply (account , region ) :
127+ def apply (account : str , region : str ) -> None :
128128 """Performs a terraform apply operation on all stacks
129129
130130 Args:
@@ -133,7 +133,7 @@ def apply(account, region):
133133 """
134134 subprocess .run (f"terraform apply -var-file=config.tfvars -var account_id={ account } -var account_region={ region } -auto-approve" , check = True , shell = True ) # nosec B602
135135
136- def destroy (account , region ) :
136+ def destroy (account : str , region : str ) -> None :
137137 """Performs a terraform destroy operation on all stacks
138138
139139 Args:
@@ -142,7 +142,7 @@ def destroy(account, region):
142142 """
143143 subprocess .run (f"terraform destroy -var-file=config.tfvars -var account_id={ account } -var account_region={ region } -auto-approve" , check = True , shell = True ) # nosec B602
144144
145- def main ():
145+ def main () -> None :
146146 # parse arguments
147147 parser = argparse .ArgumentParser (description = "Terraform Script to Deploy Stacksets" )
148148 parser .add_argument ("cmd" , help = "terraform command to run" )
0 commit comments