Skip to content

Instantly share code, notes, and snippets.

@dehio3
Created July 4, 2020 12:52
Show Gist options
  • Save dehio3/31ba6f4d8327e23236318db0116c8af0 to your computer and use it in GitHub Desktop.
Save dehio3/31ba6f4d8327e23236318db0116c8af0 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