Setup Cloudflare for AWS API Gateway
In this post I will show how to setup Cloudflare for a Serverless app built with AWS API Gateway and Lambda. For demonstration, I use a simple web app I built (rona.tomking.xyz). The app is hosted in AWS Sydney region. It displays daily Victoria COVID case and that's it.
- DNS hosting
- Free SSL certificates
- DDoS attacks mitigation up to 67 Tbps capacity
- Up to 100k workers requests and 30 scripts
- 3 Page rules
- In ACM, click Request a certificate and choose to Request a public certificate.
- Add your site's domain name to the certificate. In my case it is rona.tomking.xyz.
- Choose DNS validation and add a Name tag to the certificate.
- Submit the certificate request and you should be given a TXT record to be added to your DNS zone.
- Add the TXT record in Cloudflare and wait for ACM to validate the record. This should take no longer than an hour.
- In API Gateway, under Custom domain name click Create to create a new custom domain.
- Type in the domain name, which is rona.tomking.xyz for the demo.
- Use TLC 1.2 as recommended TLS version.
- Choose the ACM certificate we have just created and click Create domain name.
- Under API mapping select the API you want to associate with the custom domain name.
- Record the API Gateway domain name for the mapped custom domain.