Skip to content

Commit 69fd173

Browse files
committed
check if environment variables are defined before starting deploy
1 parent 9d22ee0 commit 69fd173

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
install-requirements:
22
pip install -r requirements.txt
33

4-
cloudformation-validate: install-requirements
4+
check-env-setup:
5+
python -c 'from utils import check_environment_variables; check_environment_variables()';
6+
7+
cloudformation-validate: install-requirements check-env-setup
58
python -c 'from deploy_cloudformation import validate_templates; validate_templates()';
69

710
infra-deploy: cloudformation-validate

utils.py

+8
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ def get_aws_account_id():
6060

6161
def generate_hash(n):
6262
return str(uuid4().hex[:n])
63+
64+
65+
def check_environment_variables():
66+
for env_var in ['AWS_REGION', 'ENVIRONMENT']:
67+
try:
68+
env_var_value = os.environ[env_var]
69+
except KeyError:
70+
raise KeyError(f'Environment variable {env_var} not found. Please set it up before starting.')

0 commit comments

Comments
 (0)