Using AWS Secrets Manager with Python (Lambda Console)

后端 未结 5 548
南旧
南旧 2021-01-04 11:30

I am attempting to use Secrets Manager a Lambda function in AWS. Secrets a manager is used to store database credentials to Snowflake (username, password).

I managed

5条回答
  •  萌比男神i
    2021-01-04 12:37

    • Here is how i have used it using arn, following this bloc hope that helps you.
    • Worth checking what you have used to store and accordingly use one SecretString or SecretBinary
        secrets_client = boto3.client('secretsmanager')
        secret_arn = 'arn:aws:secretsmanager:eu-west-2:xxxxxxxxxxxx:secret:dashboard/auth_token'
        auth_token = secrets_client.get_secret_value(SecretId=secret_arn).get('SecretString')
    
    • boto3 docs
    • get_secret_value Retrieves the contents of the encrypted fields SecretString or SecretBinary from the specified version of a secret, whichever contains content.
    • Your lambda role should have the following permissions depending on what is used
      • secretsmanager:GetSecretValue
      • kms:Decrypt required only if you use a customer-managed AWS KMS key to encrypt the secret. You do not need this permission to use the account's default AWS managed CMK for Secrets Manager.

提交回复
热议问题