Skip to content

Commit

Permalink
Allow settings in zappa_settings to pull from environment variables
Browse files Browse the repository at this point in the history
Partial fix for zappa#988
  • Loading branch information
dougharris committed Mar 7, 2024
1 parent e68ce5c commit 61e17e0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions zappa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ def get_stage_setting(stage, extended_stages=None):
except KeyError:
raise ClickException("Cannot extend settings for undefined stage '" + stage + "'.")

# If a value in settings matches "${SECRET_ENV}" then
# pull value from os.environ.get('SECRET_ENV')
var_pattern = re.compile(r'\$\{[^}]+}')
env_settings = {k: os.environ.get(v[2:-1]) for k, v in stage_settings.items()
if type(v) == str and var_pattern.match(v)}
stage_settings.update(env_settings)

extends_stage = self.zappa_settings[stage].get("extends", None)
if not extends_stage:
return stage_settings
Expand Down

0 comments on commit 61e17e0

Please sign in to comment.