This guide walks you through deploying the weather proxy Lambda functions to AWS.
✅ Serverless Framework - Already installed ✅ AWS CLI - Already installed ❌ AWS Credentials - Need to configure
You need AWS credentials to deploy. Since you already have an API Gateway running at https://jguz7puem3.execute-api.us-east-1.amazonaws.com/dev, you should have credentials somewhere.
Run:
aws configureYou'll be prompted for:
- AWS Access Key ID
- AWS Secret Access Key
- Default region:
us-east-1 - Default output format:
json
Check if you have AWS SSO configured elsewhere or need to set it up.
Your credentials might be in:
- IAM Console: https://console.aws.amazon.com/iam/
- Look for existing access keys or create new ones
Verify your credentials work:
aws sts get-caller-identityThis should return your AWS account information.
Navigate to the website directory and deploy:
cd /Users/jessefarnham/dev/website
serverless deploy --config serverless-weather-proxy.ymlThe deployment will:
- Create two Lambda functions (winds-aloft and metar)
- Create API Gateway endpoints
- Configure CORS automatically
- Output the API endpoint URL
After deployment, you'll see output like:
Service Information
service: website-weather-proxy
stage: dev
region: us-east-1
api keys:
None
endpoints:
GET - https://xxxxx.execute-api.us-east-1.amazonaws.com/dev/weather/winds-aloft
GET - https://xxxxx.execute-api.us-east-1.amazonaws.com/dev/weather/metar
functions:
windsAloft: website-weather-proxy-dev-windsAloft
metar: website-weather-proxy-dev-metar
IMPORTANT: Copy the base URL (e.g., https://xxxxx.execute-api.us-east-1.amazonaws.com/dev)
If you want to use your existing API Gateway (https://jguz7puem3.execute-api.us-east-1.amazonaws.com/dev), you would need to:
- Add these Lambda functions to that API Gateway manually in AWS Console
- OR merge the serverless config with your existing backend
Update src/lib/flightPlanner.js:
- Add import at the top:
import Config from '../config';- In
fetchWindsAloft()function (around line 347):
// Replace:
const url = `https://aviationweather.gov/api/data/windtemp?region=${region}&fcst=${fcst}&level=low&format=raw`;
// With (using your new endpoint):
const url = `https://YOUR_NEW_ENDPOINT.execute-api.us-east-1.amazonaws.com/dev/weather/winds-aloft?region=${region}&fcst=${fcst}`;- In
fetchMetar()function (around line 476):
// Replace:
const url = `https://aviationweather.gov/api/data/metar?ids=${icaoCode}&format=raw`;
// With:
const url = `https://YOUR_NEW_ENDPOINT.execute-api.us-east-1.amazonaws.com/dev/weather/metar?icao=${icaoCode}`;- Start the dev server:
npm start- Navigate to the flight planner page
- Try creating a flight plan from KBOS to KJFK
- Check the browser console for any errors
View logs for debugging:
# Winds aloft logs
serverless logs -f windsAloft --config serverless-weather-proxy.yml --tail
# METAR logs
serverless logs -f metar --config serverless-weather-proxy.yml --tailYou can test the endpoints with curl:
# Test winds aloft
curl "https://YOUR_ENDPOINT.execute-api.us-east-1.amazonaws.com/dev/weather/winds-aloft?region=bos&fcst=6"
# Test METAR
curl "https://YOUR_ENDPOINT.execute-api.us-east-1.amazonaws.com/dev/weather/metar?icao=KBOS"- Run
aws configureand enter your credentials - Or check ~/.aws/credentials file exists and has valid keys
- Your AWS user needs IAM permissions to create Lambda functions and API Gateway
- Required permissions: lambda:, apigateway:, iam:CreateRole, logs:*
- A stack with this name already exists
- Either remove it:
serverless remove --config serverless-weather-proxy.yml - Or deploy with a different stage:
serverless deploy --config serverless-weather-proxy.yml --stage prod
- Check that API Gateway has CORS enabled (it should be automatic with serverless config)
- Verify the Lambda functions are returning proper CORS headers
- Check browser console for specific error messages
These Lambda functions fall well within AWS free tier:
- 1M requests/month free
- 400,000 GB-seconds compute time free
- Weather data calls are typically cached for 5-30 minutes
- Expected cost: $0/month for typical usage
To remove the deployment:
serverless remove --config serverless-weather-proxy.ymlThis will delete:
- Both Lambda functions
- API Gateway endpoints
- CloudWatch log groups
- IAM roles
After successful deployment:
- Update the frontend to use the new endpoints
- Test thoroughly
- Consider adding CloudWatch alarms for errors
- Consider adding API Gateway usage plans for rate limiting
- Update your existing API Gateway config if you want to consolidate endpoints