File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,27 @@ def populate_environ_from_ssm():
2222
2323populate_environ_from_ssm ()
2424
25+
26+ def _populate_environ_from_ssm ():
27+ ssm_param_path = os .getenv ("AWS_SYSTEMS_MANAGER_PARAM_STORE_PATH" )
28+ if not ssm_param_path :
29+ return
30+
31+ from pathlib import Path
32+
33+ import boto3
34+
35+ client = boto3 .client ("ssm" )
36+ paginator = client .get_paginator ("get_parameters_by_path" )
37+ response_iterator = paginator .paginate (Path = ssm_param_path , WithDecryption = True )
38+
39+ for page in response_iterator :
40+ for param in page ["Parameters" ]:
41+ os .environ [Path (param ["Name" ]).name ] = param ["Value" ]
42+
43+
44+ _populate_environ_from_ssm ()
45+
2546os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "settings.local" )
2647os .environ .setdefault ("DJANGO_CONFIGURATION" , "Local" )
2748
You can’t perform that action at this time.
0 commit comments