/cloudformation-nodejs-webapp

AWS CloudFormation templates for deploying a Node.js Web Application with Continous Delivery

MIT LicenseMIT

AWS Serverless Node

This project contains AWS Cloudformation templates to help streamline the hosting and deployment of Node.js projects.

Getting Started

This instructions will help you have a Node project deployed to AWS.

Prerequisites

  • AWS Account
  • Node Project stored in CodeCommit
  • Root Domain setup in Route53

Deploy

AWS Serverless Node is deployed through the AWS Console (or cli).

Deploy through AWS Console

Deploy Hosting

The hosting stack has to be created first as the delivery stack references resources created in it.

  1. Download hosting.yml from this repository
  2. Login to your AWS Account
  3. Switch to the region you want to deploy from
  4. Navigate to the CloudFormation
  5. Choose Create Stack
  6. Select the hosting.yml file you downloaded and follow the prompts

Deploy Delivery

Once the hosting stack has been created successfully you can load up the delivery stack

  1. Download delivery.yml from this repository
  2. Login to your AWS Account
  3. Switch to the region you want to deploy from
  4. Navigate to the CloudFormation
  5. Choose Create Stack
  6. Select the delivery.yml file you downloaded and follow the prompts

AWS CloudFormation Templates

The following AWS CloudFormation templates are included in this project.

Hosting Template

The hosting template hosting.yml contains the following resources to server your app from.

  • S3 Bucket to store static files in.
    • With an anonymous read buck policy
  • CloudFront distribution (CDN) to server the static files.
  • Route53 record linking your url to CloudFront

Delivery Template

The delivery template delivery.yml contains the following resources to continously build your app when you commit a change.

  • CodePipeline setup to:
    • Automatically run when commit to your repository detect
    • Run CodeBuild with buildspec.yml
    • Run a custom lambda function to invalidate your CloudFront distribution
  • S3 Bucket to store build artifacts
  • Roles and Policies to give the delivery process access to required resources

Running the tests

If your download or fork the repository you can validate your changes as follows.

Hosting Tests

To test the Hosting template run the following in your terminal.

npm run test-hosting

Delivery Tests

To test the Hosting template run the following in your terminal.

npm run test-delivery

Built With

Authors

  • Marcus Riquier - Initial work - riquier