-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupdate_zappa_envs.py
More file actions
27 lines (20 loc) · 886 Bytes
/
update_zappa_envs.py
File metadata and controls
27 lines (20 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
import sys
from dotenv import dotenv_values
# Get the environment (dev or prod) from command line arguments
if len(sys.argv) != 2 or sys.argv[1] not in ['dev', 'prod']:
print("Usage: python update_zappa_envs.py [dev|prod]")
sys.exit(1)
environment = sys.argv[1]
# Load the appropriate .env file based on the environment
env_file = f"env.{environment}"
env_vars = dotenv_values(env_file)
# Load zappa_settings.json
with open("zappa_settings.json", "r") as f:
zappa_settings = json.load(f)
# Update the environment_variables section for the specific environment in zappa_settings
zappa_settings[environment]["aws_environment_variables"] = env_vars
# Save back to zappa_settings.json
with open("zappa_settings.json", "w") as f:
json.dump(zappa_settings, f, indent=4)
print(f"Environment variables from {env_file} have been added to zappa_settings.json")