Skip to content

Sofi-Tech/Pulumi

Repository files navigation

Blog Api

Description

Used Pulumi to create a blog api using AWS Lambda, API Gateway, and DynamoDB. The API is written in Javascript and uses the Serverless Framework to deploy the code to AWS.

Project Structure

stateDiagram-v2
[*] --> BlogAPI
BlogAPI --> APIGateway
BlogAPI --> database
BlogAPI --> scripts
BlogAPI --> test
BlogAPI --> utils

APIGateway --> lambdas
APIGateway --> routes
APIGateway --> auth.ts
APIGateway --> index.ts

lambdas --> comments
lambdas --> posts
lambdas --> users

routes --> comments
routes --> posts
routes --> users

database --> tables
database --> validation
Loading

The Entry point of the API

Setup

Prerequisites

  • AWS Account
  • Pulumi Account

Installation

  1. Clone the repository
  2. Install the dependencies
yarn install
  1. Add environment variables | Replace the values with your own
cp .env.example .env
  1. Create a new stack
pulumi stack init
  1. Set AWS configurations
pulumi config set aws:accessKey <access-key>
pulumi config set aws:secretKey <secret-key>
pulumi config set aws:region <region>

Note: It is advised not to use root user for the access. Instead create the access from IAM and use the access key and secret key.

  1. Create a new Pulumi access token
pulumi login
  1. Deploy the stack
yarn push

Note: If you are prompted with passphrases, you can use the following command to avoid the prompt This will remember the passphrase for the entire cli session

set PULUMI_CONFIG_PASSPHRASE="<passphrase>"
                  or
$env:PULUMI_CONFIG_PASSPHRASE="<passphrase>"

Usage

Create a SignUp

curl -X POST \
  https://<api-gateway-url>/signup  \
    -H 'Content-Type: application/json' \
    -d '{
      email: "[email protected]",
      password: "Password1@"
    }'

Pulumi does not support ignoring files, I added the json to this project which will also be pushed to aws which shouldn't be pushed. You should delete the json file after you have deployed the stack.

Resources created - 220

The total resources created by the stack are 220. The resources are divided into the following categories:

  • APIs - 4
  • Functions - 33
  • Tables - 5
  • Identity - 176
📈 Performance

Todo:

  • Write tests using vitest
  • Use jmeter to test the performance
  • Add a CI/CD pipeline
  • Add a monitoring system
  • Add a logging system

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published