How to test plan a template for github checks on repo?

73 Views Asked by At

I have a repo with atlantis integration. This repo houses many stacks that use the same modules, each stack in its own folder and with distinct tfvars.

I generate new stacks using some automation, which generates the new directories, copies a bunch of *.tf files and sets the tfvars with the correct values. Unfortunately, this integration is brittle as I have no tests that can fail PRs when something changes in the module and is not updated in the template files.

What I want is an integration test which creates a test stack, gets it planned by atlantis, fails if the plan fails, and otherwise passes.

Is this achievable?

1

There are 1 best solutions below

0
On

It doesn't sound like this problem needs to be solved by atlantis. Atlantis is more of a tool for humans.

Try this using a pipelime such as a github action workflow

  1. Create an examples/complete root module/stack
  2. Instantiate a reusable module within the new root module
  3. Write a test in terratest or similar that will run terraform init/apply/destroy
  4. Add lots of outputs and check the outputs with the test
  5. Run this test on every pull request to prevent breaking changes

See how the cloudposse github org uses this method to verify that their code is tested.