|
1 |
| -# AWS Lambda Integration with PostgreSQL and python |
| 1 | +## AWS Lambda Integration with PostgreSQL |
2 | 2 |
|
3 |
| -This repository will help in creating the AWS Lambda Function, which will connect to PostgreSQL Db over SSL. |
| 3 | +This repository will help in creating the AWS Lambda Function in Python, which will connect to PostgreSQL DB over SSL. |
4 | 4 |
|
5 |
| -# Tech Stack |
| 5 | +### Tech Stack |
| 6 | + Python 3.6 |
| 7 | + AWS Lambda |
| 8 | + PostgreSQL |
| 9 | + Psycopg2(Postgres connector) |
| 10 | + SSL |
6 | 11 |
|
7 | 12 |
|
8 |
| -## Assumption |
| 13 | +### Assumption |
9 | 14 | DB is already created with some table and access on AWS cloud.
|
10 | 15 |
|
11 |
| -## Steps Required for Project Setup |
| 16 | +### Steps Required for Project Setup |
12 | 17 | 1- Install Python3.6 or 3.8
|
13 | 18 | 2- Create a lambda project in python
|
14 | 19 | 3- Add psycopg2 dependency in your project root. (Add Image) (Reference)
|
15 | 20 | 3- Get SSL certificate from AWS (), add this SSL Certificate to your project directory. (Add Image)
|
16 | 21 | 4- Access this certificate in your code and use it in your psycopg2.connect() as sslMode and ssl_ca.(Add Image)
|
17 | 22 | 5- Zip it and upload it in AWS lambda (Note: Zip name and lambda name should be same, and lambda_funcation.py should be on root of zip)
|
18 | 23 |
|
19 |
| -## Steps Required for Project Deployment |
| 24 | +### Steps Required for Project Deployment |
20 | 25 | 1- Create Lambda furcation (Image) with same name as project zip.
|
21 | 26 | 2- Create Lambda a Role, which should have RDSAccess Permission.
|
22 | 27 | 3- Lambda should be in same VPC and subnets as PostgreSQL
|
23 | 28 | 4- Lambda should have a Security Group, this security group should have permission in PostgreSQL. So there should be a inbound rule in PostgreSQL Security Group for Lambda Security Group
|
24 | 29 |
|
25 |
| - ## Step Run |
| 30 | + ### Step Run |
26 | 31 |
|
27 |
| - ## Steps to upload ZIP file to AWS Lambda |
| 32 | + ### Steps to upload ZIP file to AWS Lambda |
28 | 33 |
|
29 | 34 |
|
30 |
| - References |
| 35 | +# References |
31 | 36 |
|
32 |
| - SSL Certificate |
33 |
| - |
34 |
| - https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html |
35 |
| - https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.SSL.html#PostgreSQL.Concepts.General.SSL.Connecting |
36 |
| - https://gist.github.com/pfigue/3440e2bc986550a6b8ec |
37 |
| - https://help.compose.com/docs/postgresql-and-python |
38 |
| - https://github.com/jkehler/awslambda-psycopg2 |
| 37 | + [SSL](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html) |
| 38 | + |
| 39 | + [SSL MODE ](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.SSL.html#PostgreSQL.Concepts.General.SSL.Connecting) |
| 40 | + |
| 41 | + [postgresql-and-python]( https://gist.github.com/pfigue/3440e2bc986550a6b8ec) |
| 42 | + |
| 43 | + [awslambda-psycopg2]( https://gist.github.com/pfigue/3440e2bc986550a6b8ec) |
| 44 | + |
| 45 | + [SSL Issue]( https://gist.github.com/pfigue/3440e2bc986550a6b8ec) |
39 | 46 |
|
40 | 47 |
|
41 | 48 |
|
|
0 commit comments