cloudposse / terraform-aws-cloudfront-cdn

Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin.
https://cloudposse.com/accelerate
Apache License 2.0
99 stars 121 forks source link

Support multiple origins #48

Closed krystan closed 3 years ago

krystan commented 3 years ago

Have a question? Please checkout our Slack Community or visit our Slack Archive.

Slack Community

Describe the Feature

I would like the cdn module to support multiple origins, and behaviours.

Expected Behavior

Should be able to specify multiple origin points (for failover purposes etc), also it should also be possible to point different behaviours to these origins, as you could configure CloudFront to route different types of requests to different origin points types.

Use Case

Currently using this module if we have multiple backends we would need to stand up two module instances because it only supports a single origin. This stops a couple of things, it makes it hard for us to serve static content from say an s3 bucket but dynamic content from an API, all under one distribution. Cached behaviours make it possible to do a path-based routing approach where this is possible but unfortunately by default this module does not support it.

Describe Ideal Solution

Able to specify multiple origin points and associate behaviours with each origin point.

Alternatives Considered

Only alternative is to either write our own module or standup separate distributions.

Additional Context

Managing multiple distributions for one thing seems a bit old school :)

A good working example of this functionality is given here

liamhelmer commented 3 years ago

Currently blocked by this as well, so figured I'd give it an upvote here as well. Is there any plan to try and implement support for this?

liamhelmer commented 3 years ago

Looked into the code... looks like doing that would be a pain for you because it would break compatibility with previous versions to implement. We haven't started using it yet though, so I might fork the code to support multiple origins as a map without any backwards compatibility. Let me know if you think there'd be other gotchas that I'm not aware of.

Nuru commented 3 years ago

I am closing this because I believe everything requested is now available in v0.21.0 of this module. If not, please open a new feature request for whatever is still missing.