Skip to main content

Git Submodules

It's possible to leverage Git submodules in your Terraform repository as a source for Terraform modules.

  1. Create a GitHub Personal Access Token with repo permissions

  2. Create the GitHub Action Secret SUBMODULE_TOKEN in your Terraform repository with the newly created personal access token value

  3. Modify your Terrateam GitHub Workflow File to include your new secret and to recursively checkout submodules

See official actions/checkout README for details

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}
  1. Create a dependency on your submodules directory in your Terrateam configuration file
info

In this example, the ec2 directory has a dependency on the modules directory which is a Git submodule

dirs:
ec2:
when_modified:
file_patterns: ["ec2/*.tf", "modules"]
  1. Create a new branch from your default branch after you merge the new GitHub Workflow File and Terrateam configuration file

  2. Checkout a new commit in your Git submodule modules directory

cd modules
git checkout <commit>
  1. Commit and push your changes to your branch

  2. Create a new pull request

The modules directory will have an update in your new pull request which in turn will trigger a terrateam plan against your ec2 directory. This is assuming autoplan is enabled.