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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.