Aws Lab Series Build and Deploy Rest Api

Aws Lab Series Build and Deploy Rest Api

Post Date : 2024-01-06T08:56:51+07:00

Modified Date : 2024-01-06T08:56:51+07:00

Category: systemdesign aws-labs

Tags: aws

First of all we have figure out our requirements and materials that we have.

Overview of requirements

Overview of the API Service

  • Our Rest API service is written in NodeJS
  • Use Relational Database
  • There is a job queue inside the service
  • The service store image on disk
  • User can upload images via this service
  • User data must be encrypted

What system needs

  1. We have a domain on godaddy and plan to use: api.domainame for api services, appname.domainname for application
  2. Both app and api must have ssl connection

Analyze requirements and design system for long-term usage

Things to cocerns:

  1. Networking


  • Route 53 for DNS
  • S3 for file storage
  • Prevent DDos Attack: AWS Shield for S3, AWS WAF for Layer 7
  • Guard network with GuardDuty

Let’s getting started

Making Route 53 the DNS service for a domain that’s in use

Reference Link :

  1. Create Hosted Zone

image image image image

  1. Update the NS records to use Route 53 name servers

Current NS records on my domain( godaddy )


After change your NS records by using 4 ns records in your hosted zone in AWS Route53, please wait a few minutes and recheck your domain ns records with nslookup command

nslookup -q=ns

Create your services in AWS

Create a test api with Amazon API Gateway

  • Create your API Endpoint
  • Request AWS Certificate for your custom domain
  • Create custom domain and map with API Endpoint
  • Test your api with mapped domain
  • Create new routes for example resources
  • Create simple lambda function to handle

Create your RDS database service in a private VPC and connect with your database

  • Create your private VPC
  • Create your RDS Security Group
  • Create your RDS in your Database
  • Create VPC Endpoint for your RDS Service


1. Create a test api with Amazon API Gateway


Create methods for root path



Create mock response template body for GET method

 "status: "success",
 "data": {
  "examples": [
    {"id": 1, "title": "Example 1"},
    {"id": 2, "title": "Example 2"},
    {"id": 3, "title": "Example 3"},
    {"id": 4, "title": "Example 4"},
    {"id": 5, "title": "Example 5"},
    {"id": 6, "title": "Example 6"},
    {"id": 7, "title": "Example 7"},
    {"id": 8, "title": "Example 8"},
    {"id": 9, "title": "Example 9"},
    {"id": 10, "title": "Example 10"}
   "pagination": {
     "pageNumber": 1,
     "pageSize": 10,
     "totalItems": 100

Then deploy your API



Let’s create production stage to map your api version


After creation, you can use invoke URL to test your api


Create custom domain name for your API Endpoint


Request AWS CA via AWS Certificate Manger ( it’s completely free )



Add API Mapping


Add Route53 Alias record point to your API Gateway Endpoint