Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if environment variables are defined before starting deploy #7

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
install-requirements:
pip install -r requirements.txt

cloudformation-validate: install-requirements
check-env-setup:
python -c 'from utils import check_environment_variables; check_environment_variables()';

cloudformation-validate: install-requirements check-env-setup
python -c 'from deploy_cloudformation import validate_templates; validate_templates()';

infra-deploy: cloudformation-validate
Expand Down
8 changes: 8 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ def get_aws_account_id():

def generate_hash(n):
return str(uuid4().hex[:n])


def check_environment_variables():
for env_var in ['AWS_REGION', 'ENVIRONMENT']:
try:
env_var_value = os.environ[env_var]
except KeyError:
raise KeyError(f'Environment variable {env_var} not found. Please set it up before starting.')