Or you could mix simple string origins with complex ones:
# serverless.yml
distribution:
component: '@serverless/aws-cloudfront'
inputs:
origins:
- http://mybucket.s3.amazonaws.com # default cache behavior uses this origin
-
url: https://my-assets.com
pathPatterns:
/static/images: # route any /static/images requests to https://my-assets.com
ttl: 10
A few notes:
The component will provision CacheBehaviors for each pathPattern declared per origin.
The first origin declared will be used for the DefaultCacheBehavior
Also, I’m using jest snapshots to test whats being passed to createDistribution and updateDistribution. This was the best way I found to make sure I don’t break existing behavior, without having to add a ton of tests considering the amount of fields cloudfront needs passing in the api.
Adds support for setting origin cache behaviors.
For example:
Or you could mix simple string origins with complex ones:
A few notes:
pathPattern
declared per origin.DefaultCacheBehavior
Also, I’m using jest snapshots to test whats being passed to
createDistribution
andupdateDistribution
. This was the best way I found to make sure I don’t break existing behavior, without having to add a ton of tests considering the amount of fields cloudfront needs passing in the api.