Untitled

mail@pastecode.io avatar
unknown
python
a year ago
537 B
2
Indexable
Never
import boto3
from botocore.exceptions import ClientError


def get_secret():

    secret_name = "SECRET_NAME"
    region_name = "eu-west-1"

    # Create a Secrets Manager client
    session = boto3.session.Session()
    client = session.client(
        service_name='secretsmanager',
        region_name=region_name
    )

    try:
        get_secret_value_response = client.get_secret_value(
            SecretId=secret_name
        )
    except ClientError as e:
        raise e

    secret = get_secret_value_response['SecretString']