Skip to content

The infrastructure code for the Conduit application, built using Amazon CDK

License

Notifications You must be signed in to change notification settings

kenyipp/realworld-nodejs-example-app-infra

Repository files navigation

Node.js / Express / Typescript / MySql / Knex Example App

Example Node (Express + Knex) codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld API spec.

Actions Status Known Vulnerabilities License

This repository contains the infrastructure code for the Conduit Application, a real-world example application adhering to the RealWorld API spec. It uses AWS CDK to manage the deployment of foundational components such as S3 buckets, IAM roles, SQS queues, and CI/CD pipelines.

Architecture Overview | Get Started | Contributing | License

Table of Contents

Architecture Overview

The project follows a monorepo structure using Turbo Repo and is divided into two repositories:

Architecture Diagram

  • S3: For object storage, used to store artifacts on CodeBuild.
  • IAM Roles: For permissions management, roles are created for CodePipeline, CodeBuild, and Lambda functions.
  • SQS: For asynchronous messaging between microservices.
  • CodePipeline: For CI/CD deployment pipelines.
  • API Gateway + Lambda: Defines the serverless microservices (located in the app repo).

Get Started

Prerequisites

  • Node.js v14+: CDK requires Node.js to be installed.
  • AWS CDK v2: Install the latest version of the CDK. npm install -g aws-cdk
  • Yarn: Use Yarn as the package manager. npm install -g yarn

Installation

  1. Clone the repository:

    git clone https://github.com/kenyipp/realworld-nodejs-example-app-infra
  2. Install dependencies:

    yarn install

Usage

  1. Bootstrap the CDK environment (if not already done):

    cdk bootstrap aws://<account-id>/<region>
  2. Synthesize the CloudFormation templates:

    cdk synth
  3. View available stacks:

    cdk list

After synthesizing the CDK program, you will see a folder called cdkgraph under the cdk.out folder. You can review the infrastructure to ensure it matches your expectations. Adjust the preset and filter in main.ts. For more details on generating the graph, click here.

Deployment

We are using Amazon CDK to deploy the application. Additionally, we have set up a CI/CD pipeline to automatically deploy the CDK application once the lint check and test cases pass.

Setup Environment Variables

Environment Variable Description Example
NODE_ENV The running environment (e.g., development, production) develop, production
AWS_ACCOUNT_ID The AWS account ID. You can get it from the AWS Management Console under "My Account" 123456789012
GITHUB_INFRA_REPOSITORY The repository name of the infrastructure realworld-nodejs-example-app-infra
GITHUB_INFRA_OWNER The owner of the infrastructure repository kenyipp
GITHUB_CONDUIT_SERVER_REPOSITORY The repository name of the server realworld-nodejs-example-app
GITHUB_CONDUIT_SERVER_OWNER The owner of the server repository kenyipp

Note: If you want to deploy the application automatically via GitHub Actions, you need to set up the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the GitHub settings.

Deploy the infrastructure using CDK

To deploy a specific stack, use:

cdk deploy <stack-name>

To deploy all stacks:

cdk deploy --all

Contributing

Please review the existing issues in this repository for areas that require improvement. If you identify any missing or potential areas for improvement, feel free to open a new issue.

License

This project is licensed under the MIT License - see the LICENSE file for details.