Skip to content

Get Secret from AWS Secrets Manager in Python

You can store secrets in AWS Secret Manager and reference their ARN in AWS Systems Secret Manager.

The below snippet allows you to specify the associated parameter to get the secret value.

import boto3 ssm = boto3.client('ssm') secretsmanager = boto3.client('secretsmanager') parameter = ssm.get_parameter(Name="/your/parameter/name", WithDecryption=True) secret = secretsmanager.get_secret_value(SecretId=parameter['Parameter']['Value']) secret = json.loads(secret['SecretString']) print(secret)
Code language: Python (python)

See also  How to Upgrade PIP
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x