README
Weather API Gateway
A hands-on project built to learn Amazon API Gateway from the ground up, built while preparing for the AWS Certified Developer - Associate exam. A single Lambda function is fronted by two different API Gateway configurations to compare their capabilities, culminating in a custom domain with HTTPS, API key authentication, and usage throttling.
Components
| Component | Purpose |
|---|---|
get-weather-demo (Lambda) | Reads lat/lon from the request, calls Open-Meteo, returns current conditions as JSON. Returns a 502 on upstream failure instead of crashing. |
weather-demo-api (HTTP API) | Lightweight, low-cost API type. Open and CORS-enabled, what the frontend calls. |
weather-demo-rest-api (REST API) | Full-featured API type. Requires an API key and sits behind a usage plan (throttling/quota), features not available on HTTP APIs. |
weather-api.joesparkman.com | Regional custom domain backed by an ACM certificate, DNS-validated and mapped through GoDaddy (this domain isn't delegated to Route 53). |
frontend/index.html | Type a city, see the current weather; geocodes the name via Open-Meteo's free geocoding API, then calls the HTTP API. |
Deploying the Infrastructure
The core resources (Lambda, both APIs, API key, usage plan) are defined in infrastructure/template.yaml and deployed with the AWS CLI:
aws cloudformation deploy \
--template-file infrastructure/template.yaml \
--stack-name weather-api-demo \
--capabilities CAPABILITY_IAM
The custom domain is intentionally left out of the template. Since joesparkman.com's DNS is managed in GoDaddy rather than Route 53, the certificate validation record and the final domain-mapping CNAME are added by hand.
Custom Domain Setup (Manual, One-Time)
- Requested a public certificate for
weather-api.joesparkman.comin ACM (us-east-2, matching the REST API's region). - Added the ACM-provided CNAME validation record in GoDaddy's DNS manager.
- Created a regional custom domain name in API Gateway and attached the certificate.
- Mapped the custom domain to the
weather-demo-rest-api/devstage. - Added a second CNAME record in GoDaddy pointing
weather-apiat the API Gateway-generated regional domain target.
Testing Summary
| Test | Result |
|---|---|
GET /weather (HTTP API, no params) | Atlanta weather, 200 |
GET /weather?lat&lon (HTTP API) | Weather for given coordinates |
| Cross-origin fetch from unrelated domain | Succeeds due to CORS |
GET /weather (REST API, no key) | 403 Forbidden |
GET /weather (REST API, valid key) | 200 with weather data |
GET /weather via custom domain, valid key | 200 with weather data |
Cost Notes
Everything here runs comfortably within AWS free-tier limits: Lambda's free tier (1M requests/month), negligible API Gateway per-request pricing, and free ACM certificates. A regional custom domain provisions no standing infrastructure (no load balancer or CloudFront distribution, unlike an edge-optimized domain). The API key is stored in SSM Parameter Store (SecureString) rather than Secrets Manager to keep ongoing cost at zero.
Skills Demonstrated
Lambda function development (Python), API Gateway HTTP and REST APIs, Lambda proxy integration, route/resource/method configuration, CORS, API keys and usage plans, AWS Certificate Manager (DNS-validated certificates), custom domain mapping (regional endpoints), third-party DNS configuration alongside AWS-native services, infrastructure as code (CloudFormation), and a small vanilla-JS frontend consuming the deployed API.