Current version does not provide ability to setup cloudfront for frontend web service.
Imagine service development is done using Angular or ReactJS. Then there are two options
- Deploy ECS Fargate cluster with frontend service running using nodejs based docker image and tie-up public alb with cloudfront.
- Deploy frontend code in S3 private bucket and expose it via cloudfront
Further note: it's difficult to do this as an add-on at the moment. I think this is because the ALB listener rules Copilot creates check the Host header of the incoming request. If the CloudFront distribution uses a domain name that Copilot is not aware of, the ALB will route the request to the default target group, which, at least for my Copilot app, doesn't route to any valid targets.
This is definitely a usecase that we'd like to support -- making it easy to a cloudfront distribution in front of load balanced web services! Once we're in a design stage, we'll update the issue here to let you know 🙇
If you have any sample cloudformation snippets that you used for cloudfront and copilot, we would really appreciate it if you share it here to ensure that we're building the right thing!
@efekarakus any updates?
Hi @bdevore17 !
Apologies, we haven't yet started on the integration of cloudfront natively into the manifest. I wonder if it's possible to create it using an addon. For example: https://github.com/aws/copilot-cli/issues/1848#issue-789372393
@efekarakus the addon method doesn't seem to work unfortunately. It just gives back 503s. My guess is that this is because the ALB and the cloudfront to not agree on what domain should be accessible.
Adding this in as an easy option would be hugely beneficial. Even without caching the benefits of cloudfront on dynamic API's are significant. https://www.youtube.com/watch?v=oVaTiRl9-v0
That talk was great, thanks for sharing!
Design has been made to begin implementing this feature! #3701 I look forward to helping create this for everyone.