03/16/2022, 12:21 AM
Hey all, I was wondering if anyone knows of a way to add cache behaviours and origins to an existing cloudfront.Distribution resource so that different stacks can add behaviours/origins to the same distribution? Ideally I was thinking of something analogous to apigatewayv2.Route which attaches a route to an existing gateway, but this doesn't seem to exist for CloudFront distribution behaviours/origins.


03/16/2022, 1:36 PM
As far as I'm aware that doesn't exist. You need to give the full cloudfront configuration when you create/update the distribution. One pattern I've used in those cases is move the resource(cloudfront in this case) to another layer. Each stack that needs to add behaviours/origins creates some kind of configuration somewhere central like ssm/s3. The cloudfront layer then fetches that and uses it as part of its create/update.


03/21/2022, 12:09 AM
Cheers for the suggestion, most likely will end up implementing that or otherwise restructuring the project to avoid the problem