Skip to main content
Lowkey ships a Terraform module at deploy/terraform/ that creates exactly the same AWS resources as the CloudFormation template — same VPC, IAM, EC2, and security services. Use it if your team already runs Terraform or if you want the plan → inspect → apply workflow before any resources are created.

Module layout

The fastest path is to let the installer run Terraform for you. Pass --method terraform:
The installer:
  1. Checks for Terraform >= 1.10 (installs it automatically if missing — no root required)
  2. Creates an S3 backend bucket with versioning and KMS encryption
  3. Writes a backend.tf pointing at that bucket
  4. Runs terraform initvalidateapply -auto-approve
If you want to review the plan before any resources are created, use the direct path below instead.

Running Terraform directly

Clone the repo and run Terraform yourself for the full plan-then-apply workflow:
profile_name and environment_name are required — they have no defaults.

Key variables

variables.tf is the authoritative source — check there for validation rules and any variables added after this page was written.

Sensitive variables and state security

litellm_api_key and provider_api_key are marked sensitive = true in Terraform, so they won’t appear in plan or apply output. They do appear in Terraform state in plaintext.
If you use litellm_api_key or provider_api_key, use a remote backend with encryption — for example, an S3 bucket with KMS, or Terraform Cloud. The installer sets this up automatically (S3 + native locking). If you deploy manually, configure a remote backend yourself before running apply.
The kiro_from_secret variable only stores a Secrets Manager reference, not the raw key. The instance resolves the actual key at install time via its IAM role. This is the recommended pattern for secrets — see Managing secrets with AWS Secrets Manager.

State management

When you use the installer, it creates an S3 backend bucket automatically:
  • Bucket name: <environment-name>-tfstate-<account-id>
  • State key: loki-agent/terraform.tfstate
  • Encryption: KMS server-side encryption, public access blocked
  • Locking: native S3 locking (Terraform >= 1.10)
The VPC is tagged with loki:tf-state-bucket and loki:tf-state-key so the uninstaller can find and clean up state. If you deploy manually, set up your own backend in backend.tf before running terraform init.

Terraform outputs

After apply, retrieve outputs with:

Watching bootstrap progress

The bootstrap script publishes progress to SSM Parameter Store regardless of which IaC tool you used:
Once you see COMPLETE, connect via SSM:

Tear-down

Remove every resource Lowkey created:
If you passed an existing VPC via existing_vpc_id, that VPC is kept — Terraform only destroys resources it created.

Parity with CloudFormation

The Terraform module and CloudFormation template are kept in sync by the repo’s test suite. If you find a parameter that exists in one but not the other, that is a bug — file an issue on GitHub.