Skip to content

Patterns for some common tasks in Pulumi, Terraform, CloudFormation tested using LocalStack

Notifications You must be signed in to change notification settings

acrois/iac-patterns

Repository files navigation

Consolidated IaC with LocalStack Demo

Dynamic Test Execution

This repository demonstrates how to use Pulumi, Terraform, and AWS CloudFormation with LocalStack for testing patterns for AWS infrastructure.

Prerequisites

Setup

  1. Clone this repository.
  2. Navigate to the repository directory.
  3. Run the following instructions.

Running LocalStack

  1. Start LocalStack using Docker Compose:

    docker compose up -d
  2. Verify that LocalStack is running:

    docker ps

Deploying Infrastructure

Follow the instructions in each tool's directory (pulumi, terraform, cloudformation) to deploy infrastructure.

Testing 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

Running Tests

Run the test script:

./tests/pulumi_bucket.js

Cleaning Up

  1. Follow the instructions in each tool's directory to clean up resources.
  2. Stop and remove LocalStack container:
    docker-compose down

Additional Notes

  • 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

About

Patterns for some common tasks in Pulumi, Terraform, CloudFormation tested using LocalStack

Resources

Stars

Watchers

Forks