0
entrypoint-job-prod: 
    AWS_PROFILE_NAME=amx-prod
    export AWS_PROFILE_NAME
    ENV=PROD
    export ENV
    python ./entry_point/entry_point.py

I am trying to set the environment variables so that the code works in the production environment. However, this does not update the environment variable. One has to manually create the environment variable in the CLI for the code to work.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Luv
  • 522
  • 5
  • 13
  • 1
    Does this answer your question? [How to maintain a shell function definition inside a Makefile?](https://stackoverflow.com/questions/73015418/how-to-maintain-a-shell-function-definition-inside-a-makefile) Also, [Force make to execute commands in the same environment](https://stackoverflow.com/questions/49217489/force-make-to-execute-commands-in-the-same-environment) – n. m. could be an AI Oct 12 '22 at 11:04

1 Answers1

1

You can simply add the variables to the command when executing:

entrypoint-job-prod: 
    ENV=PROD AWS_PROFILE_NAME=amx-prod python ./entry_point/entry_point.py

Here's a toy example demonstrating it in action:

$ cat /home/terdon/scripts/foo.py
#!/usr/bin/env python3

import os

print("AA:",os.environ['foo'])

And a Makefile that calls the script:

all: run

run: tests/main
    foo='baba' python /home/terdon/scripts/foo.py

If I now run make:

$ make
foo='baba' python /home/terdon/scripts/foo.py
AA: baba
terdon
  • 3,260
  • 5
  • 33
  • 57