-
The first step is to create Role for aws lambda with RDS permission: (ớ bước đầu tiên , tạo 1 vai trò cho func lambda với quyền truy cập vào RDS service)
- Go to IAM console , click /Role and then create role for lambda . (Truy cập vào IAM console , click tạo role, chọn mục lambda)
- For permission tab , search RDSFullAccess and select it. (Ở tab quyền , search RDSFullPermission và chọn nó)
- As end tab , we give role name and click save role. (Ở tab cuối, ta điền tên vai trò và lưu)
-
The second step is create two new security group in your existing VPC: (Ở bước thứ hai , tạo 2 security group trong default VPC đã tồn tại)
- Give the name "LambdaSecurityGroup" and save.
- Give the name "DatabaseSecurityGroup" and save.
- Now , we go to the inbound rules of "DatabaseSecurityGroup" and click edit rule and add new rule with Postgres [port 5432] and set source id is "DatabaseSecurityGroup" , click save rule.
-
The next step is create RDS instance.
- Go to RDS console and click create database , select all your configuration.
- For security group panel , we select "DatabaseSecurityGroup" and click create database.
-
The next step is create or deploy lambda function.
- I deploy serverless function with go1.x runtime (just for me).
- Next , On the Network Section or VPC section , click edit / add new VPC.
- Chose default VPC, default subnets, and "LambdaSecurityGroup" , continue wait for VPC applying.
-
Now ,create sample test environment and click test on the lambda console . It should return some output with Database writes , that's it.
Last active
September 29, 2023 03:32
-
-
Save apacheservices68/06096c2b261581ed0d8af61a473c697a to your computer and use it in GitHub Desktop.
Describle my first lambda serverless service implementation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Important note 1 :
https://stackoverflow.com/questions/76536131/connection-issue-from-lambda-to-rds-postgresql-15