in assets/functions/redshift/consumption/app.py [0:0]
def load_redshift_cred():
# Create a Secrets Manager client
session = boto3.session.Session()
client = session.client(
service_name='secretsmanager',
region_name=REGION
)
try:
get_secret_value_response = client.get_secret_value(
SecretId=SECRET_NAME
)
except ClientError as e:
raise e
else:
# Decrypts secret using the associated KMS CMK.
# Depending on whether the secret is a string or binary, one of these fields will be populated.
if 'SecretString' in get_secret_value_response:
secret = get_secret_value_response['SecretString']
else:
decoded_binary_secret = base64.b64decode(get_secret_value_response['SecretBinary'])
return json.loads(secret)