-
-
Save hassaku63/efc631ad7640dd1ae7fbf9bb9954a408 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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