Skip to content

Commit 2a09bc1

Browse files
committed
Fix for overwriting exiting process environment vars
1 parent 7498141 commit 2a09bc1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lambda/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ def lambda_handler(event, context):
2323
# Run the command as a subprocess
2424
logger.info("Running command: {}".format(cmd))
2525

26+
# For the subprocess environment, use all of the existing env vars, plus
27+
# any new ones. New ones with the same name will overwrite.
28+
new_env = os.environ.copy() | event['environment']
29+
2630
# Start the process
2731
p = subprocess.Popen(
28-
cmd, shell=False, env=event['environment'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
32+
cmd, shell=False, env=new_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2933

3034
timed_out = False
3135
try:

0 commit comments

Comments
 (0)