Skip to content

masterpointio/github-action-tf-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banner

github-action-tf-test

Release

💡 Learn more about Masterpoint below.

Purpose and Functionality

A reusable GitHub Action for testing Terraform and OpenTofu modules.

This action:

  • Automates the process of running tests on your infrastructure code
  • Supports optional AWS credentials configuration via OIDC
  • Aqua-based dependency management
  • Caching for faster execution
  • Configurable AWS region and role session name

Usage

Basic Usage

name: TF Test

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  tf-test:
    name: 🧪 ${{ matrix.tf }} test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        tf: [tofu, terraform]
    steps:
      - uses: masterpointio/github-action-tf-test/[email protected]
        with:
          tf_type: ${{ matrix.tf }}
          github_token: ${{ secrets.GITHUB_TOKEN }}

AWS Configuration

The action supports AWS authentication in two ways:

  1. Organization-level Environment Variable (Recommended)

    • Set TF_TEST_AWS_ROLE_ARN in your GitHub organization's environment variables
    • This value will be automatically available to all workflows
  2. Input Parameter

    • Pass the AWS role ARN directly in the workflow:
    with:
      aws_role_arn: "arn:aws:iam::123456789012:role/your-role"

Input Parameters

Parameter Required Default Description
tf_type Yes - Type of terraform to use (tofu or terraform)
aws_role_arn No - AWS role ARN to assume for testing (takes precedence over TF_TEST_AWS_ROLE_ARN env var)
aws_region No us-east-1 AWS region to use
github_token Yes - GitHub token for checkout
role_session_name No GitHubActions-TF-Test AWS role session name for OIDC authentication

Required Permissions

Add these permissions to your workflow:

permissions:
  actions: read
  checks: write
  contents: read
  id-token: write
  pull-requests: read

How It Works

  1. Checkout: Clones your repository
  2. Aqua Setup: Installs and configures Aqua for dependency management
  3. AWS Configuration: Sets up AWS credentials using OIDC
  4. Test Execution: Runs terraform init and terraform test (or equivalent for OpenTofu)

Dependencies

The action uses:

Built By

Powered by the Masterpoint team and driven forward by contributions from the community ❤️

Contributors

Contribution Guidelines

Contributions are welcome and appreciated!

Found an issue or want to request a feature? Open an issue

Want to fix a bug you found or add some functionality? Fork, clone, commit, push, and PR — we'll check it out.

Who We Are 𐦂𖨆𐀪𖠋

Established in 2016, Masterpoint is a team of experienced software and platform engineers specializing in Infrastructure as Code (IaC). We provide expert guidance to organizations of all sizes, helping them leverage the latest IaC practices to accelerate their engineering teams.

Our Mission

Our mission is to simplify cloud infrastructure so developers can innovate faster, safer, and with greater confidence. By open-sourcing tools and modules that we use internally, we aim to contribute back to the community, promoting consistency, quality, and security.

Our Commitments

  • 🌟 Open Source: We live and breathe open source, contributing to and maintaining hundreds of projects across multiple organizations.
  • 🌎 1% for the Planet: Demonstrating our commitment to environmental sustainability, we are proud members of 1% for the Planet, pledging to donate 1% of our annual sales to environmental nonprofits.
  • 🇺🇦 1% Towards Ukraine: With team members and friends affected by the ongoing Russo-Ukrainian war, we donate 1% of our annual revenue to invasion relief efforts, supporting organizations providing aid to those in need. Here's how you can help Ukraine with just a few clicks.

Connect With Us

We're active members of the community and are always publishing content, giving talks, and sharing our hard earned expertise. Here are a few ways you can see what we're up to:

LinkedIn Newsletter Blog YouTube

... and be sure to connect with our founder, Matt Gowie.

License

Apache License, Version 2.0.

Open Source Initiative

Copyright © 2016-2025 Masterpoint Consulting LLC

About

Reusable GitHub Action to test Terraform/OpenTofu modules

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5