简体   繁体   中英

How can I connect to an RDS PostgreSQL database using Powershell in a Lambda function?

We are trying to write a powershell script that can read data from an Aurora PostgreSQL cluster. We want to do this from within the Lambda dotnetcore3.1 environment. I don't see any documentation anywhere in google space that gives any pointers on what program/cmdlet/module could be used. In Windows, we can use an ODBC driver and/or psql. However, neither of these seem to exist in the Lambda ecosystem.

Has anyone successfully made a connection to PostgreSQL in Lambda using powershell? If so, what did you use to do it?

I reckon the core question is how to get your Lambda function access to the RDS PostgreSQL instance, which I can think of 2 approaches:

  1. Use AWS Secretes Manager to securely database username and password, retrieve them via AWS SDK during Lambda execution: https://aws.amazon.com/blogs/security/how-to-securely-provide-database-credentials-to-lambda-functions-by-using-aws-secrets-manager/

  2. Use RDS IAM Authentication to grant Lambda function access to RDS: https://aws.amazon.com/blogs/database/iam-role-based-authentication-to-amazon-aurora-from-serverless-applications/

Personally I'd recommend approach #2, though in the past I only used approach #1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM