Complete AWS serverless IoT platform with Lambda functions, RDS PostgreSQL, Amazon MQ RabbitMQ, and API Gateway.
┌─────────────┐
│ Devices │
└──────┬──────┘
│
v
┌─────────────────────────────────────────────┐
│ API Gateway HTTP API v2 │
└──────┬──────────────────────────────────────┘
│
v
┌─────────────────────────────────────────────┐
│ Lambda Functions (Python 3.10) │
│ - users - devices - telemetry │
│ - conditions - alertlogs - admin │
└──┬───────────────────────┬──────────────────┘
│ │
v v
┌──────────┐ ┌──────────┐
│ RDS PG │ │ RabbitMQ │
│ (15.4) │ │ (3.11) │
└──────────┘ └──────────┘
iot-aws-lab/
├── terraform/ # Infrastructure as Code
│ ├── modules/ # Terraform modules (11 total)
│ │ ├── vpc/
│ │ ├── rds/
│ │ ├── rabbitmq/
│ │ ├── lambda/
│ │ ├── s3/
│ │ └── ...
│ ├── main.tf
│ └── variables.tf
├── lambda/ # Lambda functions
│ ├── shared/ # Shared services layer
│ ├── users/
│ ├── devices/
│ ├── telemetry/
│ ├── conditions/
│ ├── alertlogs/
│ ├── admin/
│ └── build_all.sh
├── go-cli/ # CLI testing tool
│ ├── cmd/
│ └── go.mod
├── docker/ # Docker configurations
├── .github/workflows/ # CI/CD pipelines
└── scripts/ # Utility scripts
- AWS CLI configured (Account: 537124935206)
- Terraform >= 1.0
- Go >= 1.21
- Python >= 3.10
- Docker (optional)
cd terraform
DB_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
MQ_PASS=$(openssl rand -base64 24 | tr -dc 'a-zA-Z0-9' | head -c 24)
JWT_SECRET=$(openssl rand -base64 32)
cat > terraform.tfvars << EOF
aws_region = "ca-central-1"
environment = "dev"
project_name = "iot-lab"
db_username = "iotadmin"
db_password = "${DB_PASS}"
db_name = "iotplatform"
rabbitmq_username = "iotadmin"
rabbitmq_password = "${MQ_PASS}"
jwt_secret = "${JWT_SECRET}"
enable_ecs = false
enable_eks = false
EOFcd terraform
# Initialize Terraform
terraform init
# Plan deployment
terraform plan -out=tfplan
# Apply infrastructure
terraform apply tfplan
# Get outputs
terraform outputcd lambda
# Build all functions
chmod +x build_all.sh
./build_all.sh
# Deploy manually or use GitHub Actions
# The build creates:
# - build/shared-layer.zip
# - build/users.zip, devices.zip, telemetry.zip, etc.# Connect to RDS (use endpoint from terraform output)
psql -h <rds-endpoint> -U iotadmin -d iotplatform -f scripts/init-db.sqlcd go-cli
# Build CLI
go build -o iot-cli cmd/main.go
# Set API URL (from terraform output)
export IOT_API_URL="https://xxx.execute-api.ca-central-1.amazonaws.com"
# Test health
./iot-cli health
# Register user
./iot-cli login -e user@example.com -p password123POST /api/user- Register new userPOST /api/user/login- User loginGET /api/user- Get user profilePUT /api/user- Update user profilePATCH /api/user/password- Change passwordDELETE /api/user- Delete account
POST /api/device- Register deviceGET /api/devices- List user devicesPUT /api/device- Update deviceDELETE /api/device- Delete device
POST /api/telemetry- Submit telemetry dataGET /api/telemetry- Get telemetry historyDELETE /api/telemetry- Delete telemetry record
POST /api/conditions- Create conditionGET /api/conditions- List conditionsPUT /api/conditions- Update conditionDELETE /api/conditions- Delete condition
GET /api/alertlogs- Get alert logsDELETE /api/alertlogs- Delete alert log
GET /api/manage/users- List all usersPUT /api/manage/change-user-type- Change user typePOST /api/manage/transfer-device- Transfer device ownershipGET /api/manage/images- Get S3 presigned URL
# Start local PostgreSQL and RabbitMQ
docker-compose up -d
# Initialize database
psql -h localhost -U iotadmin -d iotplatform -f scripts/init-db.sql
# Test locally (requires local API server or use Lambda SAM)GitHub Actions workflows are configured for:
-
Terraform (
.github/workflows/terraform.yml)- Format check
- Plan on PR
- Apply on main branch push
-
Lambda Deployment (
.github/workflows/lambda-deploy.yml)- Build Lambda packages
- Deploy layer and functions
-
Go CLI Build (
.github/workflows/go-build.yml)- Build for Linux, macOS, Windows
- Upload artifacts
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYDB_PASSWORDRABBITMQ_PASSWORDJWT_SECRET
- CIDR: 10.0.0.0/16
- 2 AZs: ca-central-1a, ca-central-1b
- Public subnets: 10.0.1.0/24, 10.0.2.0/24
- Private subnets: 10.0.10.0/24, 10.0.11.0/24
- NAT Gateway for private subnet internet access
- VPC Endpoints: S3, Secrets Manager, ECR
- Engine: PostgreSQL 15.4
- Instance: db.t3.micro
- Storage: 20GB gp3 (auto-scaling to 100GB)
- Encrypted at rest
- Performance Insights enabled (7-day retention)
- Automated backups: 7 days
- Engine: RabbitMQ 3.11.20
- Instance: mq.t3.micro
- Single-instance deployment (dev)
- Auto minor version upgrades
- General logging enabled
- Runtime: Python 3.10
- Memory: 512 MB
- Timeout: 30 seconds
- VPC-attached (private subnets)
- Shared layer with dependencies
- Type: HTTP API v2
- CORS enabled
- CloudWatch logging
- 26 routes total
- Telemetry image storage
- Versioning enabled
- Encryption: AES256
- Public access blocked
- Centralized secret storage
- Automatic rotation supported
- Used by Lambda for DB/RabbitMQ credentials
- Dashboard with Lambda metrics
- Log groups for all functions
- API Gateway access logs
Development environment (dev):
- RDS db.t3.micro: ~$15/month
- Amazon MQ t3.micro: ~$40/month
- Lambda: Pay per request (~$0-5/month for low traffic)
- API Gateway: $1 per million requests
- S3: Negligible for small datasets
- NAT Gateway: ~$32/month
Total: ~$90-100/month
- All resources in VPC private subnets
- Security groups with least-privilege access
- JWT authentication with bcrypt password hashing
- Secrets stored in AWS Secrets Manager
- Encrypted RDS and S3 storage
- IAM roles with minimal permissions
- VPC endpoints to avoid internet routing
- CloudWatch dashboard for Lambda metrics
- RDS Performance Insights
- API Gateway access logs
- Lambda function logs
- CloudWatch alarms (can be configured)
This project is a complete AWS implementation matching the Azure IoT platform documented in AZURE_PROJECT_REFERENCE.md:
- Azure Functions → AWS Lambda
- Azure Cosmos DB → RDS PostgreSQL
- Azure Service Bus → Amazon MQ (RabbitMQ)
- Azure API Management → API Gateway
- Azure Blob Storage → S3
- Azure Key Vault → AWS Secrets Manager
All API endpoints, request/response structures, and business logic remain identical to ensure compatibility.
CLAUDE.md- Development guide and commandsAZURE_PROJECT_REFERENCE.md- Original Azure implementation referenceMIGRATION_PROGRESS.md- Migration status and progressgo-cli/README.md- CLI tool documentationlambda/README.md- Lambda function details (if needed)
For issues or questions:
- Check existing documentation
- Review CloudWatch logs
- Verify AWS credentials and permissions
- Ensure all required secrets are configured
Educational project for cloud migration practice.