Skip to content

Instantly share code, notes, and snippets.

@apacheservices68
Last active September 29, 2023 03:32
Show Gist options
  • Save apacheservices68/06096c2b261581ed0d8af61a473c697a to your computer and use it in GitHub Desktop.
Save apacheservices68/06096c2b261581ed0d8af61a473c697a to your computer and use it in GitHub Desktop.
Describle my first lambda serverless service implementation
  • 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)

    1. 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)
    2. For permission tab , search RDSFullAccess and select it. (Ở tab quyền , search RDSFullPermission và chọn nó)
    3. 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)

    1. Give the name "LambdaSecurityGroup" and save.
    2. Give the name "DatabaseSecurityGroup" and save.
    3. 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.

    1. Go to RDS console and click create database , select all your configuration.
    2. For security group panel , we select "DatabaseSecurityGroup" and click create database.
  • The next step is create or deploy lambda function.

    1. I deploy serverless function with go1.x runtime (just for me).
    2. Next , On the Network Section or VPC section , click edit / add new VPC.
    3. 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.

@apacheservices68
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment