Introduction
AWS Lambda enables you to run serverless functions without provisioning or managing servers. Combined with API Gateway, you can build RESTful or HTTP APIs that scale automatically from zero to thousands of requests per second. By exposing your API through an is-pro.dev subdomain, you get a clean, branded endpoint with Cloudflare's DNS management and SSL — all while keeping your infrastructure costs near zero for low-traffic APIs.
Prerequisites
- An AWS account with Lambda and API Gateway access
- The AWS CLI installed and configured locally (optional but helpful)
- An is-pro.dev subdomain registered at dash.is-pro.dev
- Basic knowledge of REST APIs and HTTP methods
Step 1: Create Your Lambda Function
Log into the AWS Management Console and navigate to Lambda.
Click "Create function" and choose "Author from scratch". Give
your function a name (e.g., my-api-handler).
Select a runtime — Node.js 18 or Python 3.11 are good choices.
For permissions, create a basic execution role with Lambda
basic execution permissions. Write your function code that
handles API requests. A simple example returns a JSON
response:
exports.handler = async (event) => { return { statusCode:
200, body: JSON.stringify({ message: 'Hello from Lambda' })
} }. Click "Deploy" to save your function. Test it with a sample
event to confirm it returns the expected response.
Step 2: Set Up API Gateway
Navigate to API Gateway in the AWS console. Click "Create API"
and choose "REST API" or "HTTP API". HTTP API is simpler and
cheaper for most use cases. Select "Build" and give your API a
name (e.g., my-api). Create a route — for a basic
API, add a GET / route and a
GET /{proxy+} catch-all route. Attach your Lambda
function as the integration target. Deploy your API to a stage
(e.g., prod). API Gateway assigns an invoke URL
like
https://abcdef123.execute-api.us-east-1.amazonaws.com. Test this URL in your browser or with curl to verify your
Lambda responds correctly.
Step 3: Configure Custom Domain in API Gateway
In API Gateway, go to "Custom domain names" in the left
navigation. Click "Create". Enter your is-pro.dev subdomain
(e.g., api.is-pro.dev). For the endpoint
configuration, choose "Regional" (not Edge-optimized, since
Cloudflare will handle CDN). Create a TLS certificate using
AWS Certificate Manager (ACM) in the same region as your API
Gateway. ACM requires domain verification — it will give you a
CNAME record to add to your DNS. You need to request the
certificate for api.is-pro.dev and optionally a
wildcard *.api.is-pro.dev. Once the certificate
is issued (verification usually takes a few minutes), select
it in the API Gateway custom domain settings and map your API
stage to a path (e.g., map GET / to
$default).
Step 4: Configure DNS in the is-pro.dev Dashboard
Open the is-pro.dev DNS dashboard. You need to add two DNS
records. First, add the CNAME record that ACM provided during
certificate verification (this verifies domain ownership for
AWS). Second, add a CNAME record pointing your API subdomain
to the API Gateway regional domain name, which looks like
d-abc1234.execute-api.us-east-1.amazonaws.com.
Important: set the proxy status to DNS-only (gray cloud) for
the API Gateway CNAME record. Proxied mode (orange cloud) can
interfere with API Gateway's certificate validation and may
cause issues with non-HTTP traffic patterns used by API
Gateway.
Step 5: Configure CORS for Your API
If your API is called from a frontend application on a
different domain, you need to configure CORS (Cross-Origin
Resource Sharing). In API Gateway, you can enable CORS at the
API level or for individual routes. Add the
Access-Control-Allow-Origin header with your
frontend domain (or * for development). Also add
Access-Control-Allow-Methods and
Access-Control-Allow-Headers. If your Lambda
returns these headers directly, ensure they are included in
the response. Test CORS by making an HTTP request from your
frontend and checking for CORS errors in the browser console.
Use the HTTP Headers Checker tool on is-pro.dev to verify your
API's response headers.
Step 6: Monitor and Optimize
Set up CloudWatch monitoring for your Lambda function to track invocation counts, error rates, and duration. Configure basic alerts for 5xx errors exceeding a threshold. For cost management, monitor the AWS Free Tier limits: 1 million Lambda requests and 1 million API Gateway requests per month. Consider using Cloudflare's caching for GET endpoints that return static or slowly-changing data. Add rate limiting via API Gateway's usage plans if your API is publicly accessible. Use the is-pro.dev uptime monitoring tools to track your API availability.
Best Practices
- Use environment variables in Lambda for configuration like database connection strings and API keys
- Implement proper error handling with consistent JSON error responses
- Enable AWS X-Ray tracing for debugging performance bottlenecks
- Set API Gateway throttling limits to protect against unexpected traffic spikes
Conclusion
AWS Lambda, API Gateway, and an is-pro.dev subdomain form a powerful serverless stack for building and exposing APIs. The Lambda function handles business logic, API Gateway manages HTTP routing and scaling, and your subdomain provides a clean, branded endpoint with professional DNS management.
FAQ
Does this setup work with the AWS Free Tier?
Yes, AWS Free Tier includes 1 million Lambda requests and 1 million API Gateway requests per month for the first 12 months. After that, costs remain very low for small to moderate traffic.
Can I use this with other cloud providers like Google Cloud Functions or Azure Functions?
Yes, the DNS configuration approach is similar for any cloud provider. Instead of API Gateway, you would use Cloud Run, Cloud Functions, or Azure API Management with the same CNAME-based custom domain setup.
Why does my API return a 403 error after setting up the custom domain?
This usually indicates API Gateway's resource policy or AWS WAF is blocking the request. Check your API's resource policy to ensure it allows requests from the custom domain, and verify that the API Gateway stage is properly mapped to the custom domain path.
FAQ
Is API setup free on is-pro.dev?
Yes, all subdomains on is-pro.dev include free DNS management and SSL certificates.
How long does DNS take to propagate?
Cloudflare typically propagates DNS changes within seconds to a few minutes globally.
Can I use this for commercial projects?
Yes, is-pro.dev subdomains can be used for personal and commercial projects within our fair use policy.