integ

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

README

Integration Tests

[!WARNING] Make sure to build (pnpm compile) before running e2e. terratest only uses the compiled lib folder.

terratest.gruntwork.io is a golang library of modules for IaC testing.

Refer to their excelent Quick Start docs for an introduction on how to use terratest.

Launch an Authenticated AWS Shell.

E2E User Setup

To run the integration tests, you must not use the root AWS account. Instead, create a dedicated IAM user with administrative privileges.

  1. Create the IAM User:

    aws iam create-user --user-name terraconstructs-e2e
    
  2. Attach Administrator Policy:

    aws iam attach-user-policy --user-name terraconstructs-e2e --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
    
  3. Create and Configure Access Key:

    aws iam create-access-key --user-name terraconstructs-e2e
    

    This command will output an AccessKeyId and a SecretAccessKey. Use these to configure a new AWS CLI profile:

    aws configure --profile terraconstructs-e2e set aws_access_key_id <YOUR_ACCESS_KEY_ID>
    aws configure --profile terraconstructs-e2e set aws_secret_access_key <YOUR_SECRET_ACCESS_KEY>
    
  4. Set the AWS_PROFILE Environment Variable:

    Before running the tests, set the AWS_PROFILE environment variable to use the newly created profile:

    export AWS_PROFILE=terraconstructs-e2e
    

Run all e2e tests:

[!IMPORTANT] Ensure bun is installed and available on $PATH for terratest to synth. To manually run the integration "apps", use bun run.

go test -v -count 1 -timeout 180m ./...

[!IMPORTANT] Running all e2e tests will take significant amount of time and is not recommended, use individual make targets per namespace: i.e. cd staticsite; make public-website-bucket

Make targets

[!IMPORTANT] If you encounter any issues with the awk commands used, you might need to install GNU versions of these tools via Homebrew and ensure gnubin is first on $PATH.

brew install awk

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t *testing.T, input any, assertions []Assertion)

Assert asserts the given input against the provided assertions. Fails the test if any assertion fails.

func AssertE

func AssertE(input any, assertions []Assertion) error

AssertE asserts the given input against the provided assertions and returns an error if any assertion fails.

func TerraformOutputJMES

func TerraformOutputJMES[T any](t *testing.T, terraformOptions *terraform.Options, query string) T

TerraformOutputJMES calls terraform output, searches values using JMESPath and converts to the desired type. This fails the test on any errors

func TerraformOutputJMESAny

func TerraformOutputJMESAny(t *testing.T, terraformOptions *terraform.Options, query string) interface{}

TerraformOutputJMESAny calls terraform output and searches values using JMESPath. This fails the test on any errors

func TerraformOutputJMESAnyE

func TerraformOutputJMESAnyE(t *testing.T, terraformOptions *terraform.Options, query string) (interface{}, error)

TerraformOutputJMESAnyE calls terraform output and searches values using JMESPath.

Types

type Assertion

type Assertion struct {
	Path           string  // JMESPath of the value to assert
	Exists         bool    // Whether the value should exist, `true` if ExpectedRegexp is provided
	ExpectedRegexp *string // Regexp to match the value against
}

Directories

Path Synopsis
aws

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL