How to do it...

  1. Create the project from the following template:
$ sls create --template-url https://github.com/danteinc/js-cloud-native-cookbook/tree/master/ch4/cdn-site --path cncb-cdn-site
  1. Navigate to the cncb-cdn-site directory with cd cncb-cdn-site.
  2. Review the file named serverless.yml with the following content:
service: cncb-cdn-siteprovider:  name: awsplugins:  - serverless-spa-deploy  - serverless-spa-configcustom:  spa:    files:      - source: ./dist        globs: '**/*'        headers:          CacheControl: max-age=31536000 # 1 year    redirect: true  dns:    hostedZoneId:  Z1234567890123    domainName: example.com    endpoint: www.${self:custom.dns.domainName}
  1. Update the serverless.yml file with your hostedZoneId and domainName.
  2. Install the dependencies with npm install ...

Get JavaScript Cloud Native Development Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.