Skip to content
AmFlint edited this page Jun 4, 2019 · 1 revision

Deploy the Application

This API uses AWS Lambda runtime/hosting, based on node.js runtime (backed by TypeScript and Webpack), with database storage on AWS DynamoDB.

Very importantly, this project uses the Serverless Framework to manage deployment/project lifecycle. It allows us to create all needed resources, manage our Infrastructure As Code (deployment logic/resource needs are specified inside main serverless.yml file), it creates and provisions everything in one command line (AWS DynamoDB tables, S3 Buckets, creates Lambda functions, packages and deploy code, create and configure API Gateway endpoints properly).

CI/CD

At the moment, the following process is fully automated, thanks to CI/CD utilities such as CircleCI, you may find the pipeline configuration in .circleci directory in this project.

Here are the different steps of CI/CD on this project:

  • Run Linter
  • Run Unit Tests
  • develop branch: Run serverless deploy, which deploys/provisions all resources for this project, and uploads live documentation to APIGateway. It also takes care of seeding the database.
  • develop branch: Download generated documentation from AWS APIGateway formatted as OpenAPI 3.0, and upload it to a S3 Bucket, and update ACL to allow public access to this file, so our Swagger may access to the file (for swagger documentation).

Requirements

In order to deploy this project, you will need:

  • An AWS Account
  • AWS Credentials (IAM), please follow this guide in order to get started properly.
  • Node.js, npm and Serverless CLI installed:
    npm install -g serverless

How to deploy

Set up AWS Credentials

Once you created your account, and properly configured AWS IAM roles for Serverless CLI, and you retrieved your access/secret keys, you may do either one of the following:

  • Set them as environment variables:
    export AWS_ACCESS_KEY_ID=<access-key>
    export AWS_SECRET_ACCESS_KEY=<secret-key>
    serverless deploy
  • Use custom AWS profiles
    # Make sure you followed the guide linked above, then select your profile at deployment
    serverless deploy --aws-profile yourProfile

Deploy

Nothing is easier than this step:

serverless deploy

Your code will get built (from TypeScript to JavaScript with Webpack plugin), then processed by AWS Lambda, and get deployed. Other resources specified in serverless.yml will also be processed, and documentation will be generated inside AWS APIGateway based on serverless-aws-documentation plugin.

Clone this wiki locally