1 year ago
#273169
Rodrigo Francisquini
How to redirect routes from cloudfront to an API Gateway that contains multiple services created by serverless framework?
I created an API Gateway using AWS CDK and I am using the serverless framework to create 3 different API's using the same API Gateway. My API Gateway structure looks like this:
/
/service1
/service1/{proxy}
/service2
/service2/{proxy}
/service3
/service3/{proxy}
I configured API Gateway as the origin of a cloudfront, redirecting requests coming from "domain/api" to API Gateway. The problem is that the path in API Gateway needs to match the selected path in cloudfront, so I would have to change it to something like:
/
/api/service1
/api/service1/{proxy}
/api/service2
/api/service2/{proxy}
/api/service3
/api/service3/{proxy}
This solution would be ok, but I can't share the "/api" path between multiple different services using the serverless framework. I would like the API Gateway rootPath to be "/api" and not "/", but I haven't been able to perform this configuration with the CDK. I wish I had something like this, is it possible?
/api
/service1
/service1/{proxy}
/service2
/service2/{proxy}
/service3
/service3/{proxy}
So that requests with /api were redirected by cloudfront to API Gateway, but could be defined as /service1 in the service, not /api/service1.
amazon-web-services
aws-api-gateway
amazon-cloudfront
serverless-framework
aws-lambda-edge
0 Answers
Your Answer