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-invalidate --path cncb-cdn-invalidate
  1. Navigate to the cncb-cdn-invalidate directory with cd cncb-cdn-invalidate.
  1. Review the file named serverless.yml with the following content:
service: cncb-cdn-invalidateprovider:  name: aws  runtime: nodejs8.10  ...functions:  load:    ...  trigger:    handler: handler.trigger    events:      - sns:          arn:             Ref: BucketTopic          topicName: ${self:service}-${opt:stage}-trigger    environment:      DISABLED: false      DISTRIBUTION_ID:        Ref: ApiDistributionresources:  Resources:    Bucket:      Type: AWS::S3::Bucket      DependsOn: [ BucketTopic, BucketTopicPolicy ]      Properties:        NotificationConfiguration ...

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.