Skip to content

Instantly share code, notes, and snippets.

@jimbo8098
Created August 5, 2023 10:05
Show Gist options
  • Save jimbo8098/dfe7b8130b93dbe6fe0b790eb853f546 to your computer and use it in GitHub Desktop.
Save jimbo8098/dfe7b8130b93dbe6fe0b790eb853f546 to your computer and use it in GitHub Desktop.
Retrieve SecretsManager secret using Lambda execution role

This simple script retrieves a secret of your choice from SecretsManager using the Lambda's provided event. Simply provide the payload:

{
  "secret":"<identifier>"
}

where identifier is either the ID of the secret or the ARN of it.

aws_lambda_powertools
from aws_lambda_powertools.utilities import parameters
def handler(event,context):
value = parameters.get_secret(event["secret"])
print(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment