amplify-education / serverless-domain-manager

Serverless plugin for managing custom domains with API Gateways.
MIT License
939 stars 232 forks source link

Attach custom domain name to s3 bucket as well? #108

Closed xingped closed 5 years ago

xingped commented 6 years ago

I'm not sure if this should be an issue for this repo or serverless-finch, but I was wondering if there was a way (or it could be considered to be added) to automatically add the custom domain mapping to an s3 bucket as well for static files like the one that can be created with serverless-finch?

captainsidd commented 6 years ago

Hey there! Sorry for the delay.

It doesn't seem like this would be something that we could do, since the way this plugin works is by creating CNAME/Alias records for the urls generated with API Gateway. If you can come up with a PR to support this, we would be open to adding this to the plugin.

Thanks!

captainsidd commented 5 years ago

Closing this issue, as it seems better suited for a separate plugin that specifically interacts with S3 buckets instead of API Gateway.

Vandivier commented 5 years ago

I'd like to reopen.

OP wasn't sure if S3 domain config is a task for serverless-domain-manager or serverless-finch; according to finch's creator it's not currently supported there. In fact, he refers to this project.

It's a good architecture to have some services and a client, then expose them to the public through ApiGateway. In this architecture ApiGateway and associated domain config is parent to S3, Lambda, EC2, ECS, and whatever other resources might receive proxied requests. ApiGateway is the proxy orchestrator.

Currently I'm able to do this:

However, an update to serverless.yml will break the manual S3 configuration. It will need to be manually fixed. As far as I can tell, that is the status quo and neither serverless-finch nor any other framework can address that in an automated way.

Vandivier commented 5 years ago

Related StackOverflow article here with a pertinent comment on how to configure this:

"Be aware that exactly the same objective can be accomplished with better performance and significantly lower cost by using a single CloudFront distribution to front-end both your API and bucket. (API Gateway $3.50/MM req to S3 vs CF $1.00/MM req to S3.)"

I notice that serverless-domain-manager already utilizes CloudFront and the linking of that resource to ApiGateway.