Skip to content

Instantly share code, notes, and snippets.

@alichherawalla
Last active August 14, 2023 21:43
Show Gist options
  • Save alichherawalla/411b1bccd3383c2948aeb129e0b70040 to your computer and use it in GitHub Desktop.
Save alichherawalla/411b1bccd3383c2948aeb129e0b70040 to your computer and use it in GitHub Desktop.
Reusable env related functions
import os
import sys
from awsglue.utils import getResolvedOptions
def load_env(environment):
if environment == "local":
from dotenv import load_dotenv
load_dotenv(".env")
def get_env_or_args(env_name):
try:
if os.environ.get(env_name):
return os.getenv(env_name)
else:
return getResolvedOptions(sys.argv,[env_name])[env_name]
except:
return ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment