Skip to content

Instantly share code, notes, and snippets.

@hassaku63
Forked from dehio3/settings.py
Created August 23, 2020 07:01
Show Gist options
  • Save hassaku63/efc631ad7640dd1ae7fbf9bb9954a408 to your computer and use it in GitHub Desktop.
Save hassaku63/efc631ad7640dd1ae7fbf9bb9954a408 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from dotenv import load_dotenv
from pathlib import Path
from botocore.exceptions import ClientError
import boto3
import json
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
GHE_ORGANIZATIONS = os.getenv('GHE_ORGANIZATIONS')
AWS_SERCRET_ID = os.getenv('AWS_SERCRET_ID')
SLACK_WEBHOOK_URL = os.getenv('SLACK_WEBHOOK_URL')
if AWS_SERCRET_ID:
try:
client = boto3.client(service_name='secretsmanager')
get_secret_value_response = client.get_secret_value(
SecretId=AWS_SERCRET_ID)
except ClientError as e:
raise e
else:
secret = json.loads(get_secret_value_response['SecretString'])
GHE_ACCESS_TOKEN = secret['GHE_ACCESS_TOKEN']
else:
GHE_ACCESS_TOKEN = os.getenv('GHE_ACCESS_TOKEN')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment