Bar Service Infrastructure using AWS and CDK. For details, see the project on github.
AWS CDK Infrastructure package that creates:
- An ECS cluster in a multi-AZ VPC
- An application load balanced Fargate web-service that runs on the above ECS Cluster
- A CodeBuild spec that builds the web-service sources from Github and pushes to ECR repo
- A CodePipeline pipeline with stages to build and deploy changes to the web-service
The infra sources are organized into the following files:
- package.json: Package dependecies for npm
- webServiceCluster.ts: ECS Cluster construct within a dual AZ VPC
- webservice.ts: WebService construct that defines an application load balanced fargate service
- webServicePipeline.ts: CodePipeline construct with CodeBuild from Github source
- webServiceStack.ts: Full web service stack that creates a cluster, web-service and a pipeline
-
Install Homebrew
Download and install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install nvm
Install latest version of nvm:
brew install nvm
-
Install any version of Node
Install latest version of node:
nvm install node
or any specific version of node:
nvm install 14.17.6
-
Install CDK
Follow the instructions from AWS CDK Getting Started to configure your AWS account and install CDK
-
Run a clean build
Run a custom clean build command (installing dependencies is handled part of the command)
npm run clean-build
-
Deploy ECR Repo
Deploy ECR repo to hold the containers for Bar Service Server
cdk deploy repo
-
Deploy Bar Server
Note: Between the above step and this step, a valid server container image should be pushed to the ECR repository that was deployed above. Otherwise, there would be nothing to deploy on ECS.
Deploy the bar service server to an ECS cluster Fargate Service backed by an Application Load Balancer.
cdk deploy service