Terraform/OpenTofu configurations for running Scalr agent pools as serverless workloads on AWS or Azure.
Each webhook from Scalr spins up an ephemeral container that executes a single Terraform run and exits. Containers scale to zero when idle — you only pay for actual compute time.
Scalr.io ── webhook ──> API Gateway ── auth ──> Ephemeral Container (scalr/agent)
|
Persistent Cache (providers & modules)
- Scalr needs to execute a Terraform run and sends a webhook to the configured endpoint
- The API gateway authenticates the request via API key
- An ephemeral container starts with the Scalr agent (
SCALR_SINGLE=true) - The agent connects to Scalr, executes the run, and exits
- Persistent storage caches Terraform providers and modules across runs
| AWS | Azure | |
|---|---|---|
| Webhook gateway | API Gateway (REST API) + Lambda | API Management (Consumption) |
| Compute | ECS Fargate | Container Apps Job |
| Cache storage | EFS | Azure Files |
| Cold start | ~10-20s | ~5-15s |
| Docs | aws/README.md |
azure/README.md |
- Terraform >= 1.0 or OpenTofu
- Scalr account with API access (
SCALR_HOSTNAMEandSCALR_TOKENenvironment variables) - Cloud provider CLI authenticated (AWS CLI or Azure CLI)
cd aws # or: cd azure
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars
tofu init && tofu applySee the platform-specific README for detailed configuration, cost estimates, and troubleshooting.
Build your own image with pre-cached providers:
FROM scalr/agent:latest
COPY providers/ /terraform-cache/- Fork the repository
- Create a feature branch
- Test your changes
- Submit a pull request
MIT License - see LICENSE file for details