Inject RDS secrets to Python in Lambda

0

I need to transfer SQL Server RDS' secrets into my Python code that will be ran by Lambda.

What would be best approach to handle such transfer? Sholud it be done with boto3 or/with AWS' Secrets Manager?

Sample Python code:

import pyodbc 

def lambda_handler(event,context):
    conn = pyodbc.connect('Driver={SQL Server};'
                          'Server=server_name;'
                          'Database=db_name;'
                          'Trusted_Connection=yes;')

    cursor = conn.cursor()
    cursor.execute('SELECT * FROM db_name.Table')

    for row in cursor:
        print(row)
1

1

This is a great walkthrough with code examples and more importantly, shows how to setup the exceptions in Python for boto3 and SecretsManager.

https://aws.amazon.com/blogs/security/how-to-securely-provide-database-credentials-to-lambda-functions-by-using-aws-secrets-manager/

2021-11-24 20:39:02

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................