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.
- Download
hosting.yml
from this repository - Login to your AWS Account
- Switch to the region you want to deploy from
- Navigate to the CloudFormation
- Choose
Create Stack
- 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
- Download
delivery.yml
from this repository - Login to your AWS Account
- Switch to the region you want to deploy from
- Navigate to the CloudFormation
- Choose
Create Stack
- 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
- cfn-lint - CloudFormation Validator
Authors
- Marcus Riquier - Initial work - riquier