This repository demonstrates how to use Pulumi, Terraform, and AWS CloudFormation with LocalStack for testing patterns for AWS infrastructure.
- Bun
- Docker and Docker Compose
- Pulumi CLI
- Terraform CLI
- AWS CLI
- About 3:50
- Clone this repository.
- Navigate to the repository directory.
- Run the following instructions.
-
Start LocalStack using Docker Compose:
docker compose up -d
-
Verify that LocalStack is running:
docker ps
Follow the instructions in each tool's directory (pulumi
, terraform
, cloudformation
) to deploy infrastructure.
After deploying infrastructure using any of the IaC tools, you can test the creation of resources using AWS CLI commands targeting LocalStack.
Example command to list S3 buckets:
aws --endpoint-url=http://localhost:4566 s3 ls
Run the test script:
./tests/pulumi_bucket.js
- Follow the instructions in each tool's directory to clean up resources.
- Stop and remove LocalStack container:
docker-compose down
- This demo uses fixed AWS credentials (
test
for access and secret key) as specified in the.env
file. - Ensure that the AWS region and endpoint in your IaC scripts match those in LocalStack.
- Instead of explicitly passing credentials to several specific tool config formats, we will use env vars to set them across all tools.
- Tests are anything that is executable that returns a non-zero (e.g. 1) exit code on failure and zero (0) on success.
- Note that for Bun, it is important to run the script from the project root, and not go into the test directory, because Bun will get the
.env
file from the project root