A production-ready Proof-of-Concept (PoC) demonstrating how to use Fakecloud as a fast, free, local AWS emulator sandbox to test terraform plan and terraform apply before promoting infrastructure changes to your real AWS environment.
This project provisions an AWS REST API Gateway integrated with a Python AWS Lambda function via AWS_PROXY, and includes automated integration testing using the official first-party Fakecloud Python SDK (fakecloud) and pytest.
graph LR
subgraph Local Environment
User[Developer / CI Pipeline] -->|terraform apply| TF[Terraform AWS Provider]
TF -->|http://localhost:4566| FC[Fakecloud AWS Emulator]
FC -->|Provisions| APIGW[REST API Gateway\n/hello]
FC -->|Deploys Container| Lambda[AWS Lambda Container\nPython 3.11]
FC -->|Configures| IAM[IAM Roles & Policies]
User -->|HTTP GET/POST| APIGW
APIGW -->|AWS_PROXY Integration| Lambda
Lambda -->|HTTP 200 JSON Response| User
Pytest[Fakecloud Test SDK / pytest] -.->|Introspects Invocations| FC
end
- 100% Free & Open-Source: Free forever with no accounts, no auth tokens, and no commercial paywalls.
- Deep Conformance: Conformance validated directly against AWS Smithy API models.
- Real Container Execution: Executes Lambda functions inside real isolated AWS Lambda runtime containers (
public.ecr.aws/lambda/python:3.11). - First-Party Test SDK: Deep introspection of emulator internals (Lambda invocation payloads, warm container pools, health metrics) without flaky log parsing.
git clone https://github.com/emocado/fakecloud-apigw.git
cd fakecloud-apigwStart Fakecloud in Docker with host-gateway networking:
docker-compose up -dOr on Windows PowerShell:
.\start-fakecloud.ps1Verify Fakecloud is running:
curl http://localhost:4566/_fakecloud/health# Initialize providers
terraform init
# Review execution plan
terraform plan
# Apply infrastructure to Fakecloud sandbox
terraform apply -auto-approveInstall test dependencies:
pip install fakecloud pytest requests boto3Run the pytest suite:
pytestOr with PowerShell helper:
.\run-tests.ps1What the SDK tests verify:
- ✅
test_fakecloud_health: Verifies emulator status and active service registrations (apigateway,lambda,iam). - ✅
test_apigateway_get_request: Sends HTTP GET via API Gateway and asserts exact payload captured inside Fakecloud withfc.lambda_.get_invocations(). - ✅
test_apigateway_post_request: Sends HTTP POST with JSON body and asserts proxy payload forwarding. - ✅
test_boto3_direct_lambda_invocation: Verifies direct Lambda execution using the standard AWS Boto3 SDK against Fakecloud. - ✅
test_fakecloud_warm_containers: Introspects the warm container pool usingfc.lambda_.get_warm_containers().
# Run the PowerShell test script
.\test-endpoint.ps1Or test with curl:
# Get the API ID from Terraform outputs
API_ID=$(terraform output -raw api_id)
# Test GET Request
curl -i -H "Host: ${API_ID}.execute-api.us-east-1.amazonaws.com" \
"http://localhost:4566/dev/hello?name=Developer"
# Test POST Request
curl -i -X POST -H "Host: ${API_ID}.execute-api.us-east-1.amazonaws.com" \
-H "Content-Type: application/json" \
-d '{"message":"testing from curl"}' \
"http://localhost:4566/dev/hello"HTTP/1.1 200 OK
Content-Type: application/json
Access-Control-Allow-Origin: *
{
"status": "success",
"message": "Hello from Lambda running in Fakecloud sandbox!",
"timestamp": "2026-08-30T15:09:20.079123Z",
"environment": "dev",
"request": {
"httpMethod": "GET",
"path": "/dev/hello",
"queryStringParameters": {
"name": "Developer"
},
"body": {}
}
}The Terraform configuration in provider.tf is fully dynamic:
In terraform.tfvars:
# For Local Sandbox (Fakecloud)
use_fakecloud = true
fakecloud_endpoint = "http://localhost:4566"
# For Real AWS Deployment
# use_fakecloud = falseWhen use_fakecloud = false, Terraform automatically disables local endpoint overrides, skips mock credentials, and deploys directly to your real AWS account using standard AWS credentials (~/.aws/credentials or AWS environment variables).
├── apigateway.tf # REST API Gateway resources, methods, and integrations
├── docker-compose.yml # Docker Compose config for Fakecloud
├── iam.tf # IAM Lambda execution role & policy attachment
├── lambda.tf # Lambda packaging & deployment definition
├── outputs.tf # Output values (API ID, stage, invoke URLs, host headers)
├── provider.tf # Dynamic AWS provider with conditional local endpoints
├── pytest.ini # Pytest configuration
├── README.md # Project documentation
├── run-tests.ps1 # Test runner script
├── start-fakecloud.ps1 # Startup helper script
├── variables.tf # Input variable declarations
├── versions.tf # Terraform and provider version constraints
├── src/
│ └── lambda/
│ └── index.py # Python Lambda proxy handler
└── tests/
└── test_apigw_lambda.py # SDK integration test suite
This project is licensed under the MIT License.