We have an AWS lambda function and is mapped to API gateway.
I want to enable Geo restriction on our API which is a feature in cloud front. Want it so that my lambda doesn't get hit from countries where we are not providing my services.
I believe API Gateway uses Cloud front by default but I am not able to see any related cloud front Distribution.
Was wondering what is the way to enable Geo Restriction while using API Gateway and AWS Lambda.
While it seems API Gateway is using CloudFront. It is not possible to configure Geo restrictions on API Gateway itself (At least as of now). You can create a distribution with CloudFront and point the origin to API Gateway and have your Geo restriction enabled.
Additionally, you can also enable x-API-key to protect your endpoint from API-Gateway from CloudFront.
One more way of controlling from code is through analyzing CloudFront-Viewer-Country header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With