A sample of a Terraform configuration file highlighting its usage with LocalStack init hooks and Testcontainers
- A valid LocalStack for AWS license. Your license provides a
LOCALSTACK_AUTH_TOKENto activate LocalStack. - Docker.
lstk, the LocalStack CLI. Install it withmake install, orbrew install localstack/tap/lstk.- Java 21 and Maven.
Authenticate once with lstk login, or export your token:
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>lstk reads the container's environment variables and bind mounts from .lstk/config.toml,
which installs the localstack-extension-terraform-init extension and mounts terraform/ into
/etc/localstack/init/ready.d so main.tf is applied as a READY init hook.
make build # builds the Lambda JAR and stages it into terraform/target/
make start # lstk startOnce the Ready. message appears, exercise the stack:
lstk status # list the deployed resources
./invoke.sh # POST two products, then GET one backStop it with make stop.
docker-compose.yml is an alternative to lstk and mounts the same paths:
docker compose up