Skip to content

Repository template for a basic (cloud-agnostic) Terraform module.

License

Notifications You must be signed in to change notification settings

politician/template-terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e57a8ef · Jun 10, 2022

History

49 Commits
Jun 9, 2022
Jun 10, 2022
Jun 6, 2022
Jun 6, 2022
Jun 8, 2022
Jun 8, 2022
Jun 9, 2022
Jun 6, 2022
Jun 9, 2022
Jun 10, 2022
Jun 6, 2022
Jun 9, 2022
Jun 6, 2022
Jun 6, 2022
Jun 10, 2022
Jun 8, 2022
Jun 8, 2022
Jun 8, 2022
Jun 6, 2022
Jun 8, 2022
Jun 6, 2022

USING THIS TEMPLATE

  1. Search/replace for these variables:

    • {{repo_owner}} - GitHub repository username
    • {{repo_name}} - GitHub repository name
    • {{project_name}} - Project name
    • {{project_tagline}} - Project tagline
    • {{security_email}} - Email to send vulnerabilities add -noreply before the @
    • {{author_name}} - Your name
    • {{docs_base_url}} - Base URL to the documentation (no trailing slash). It could be:
      • https://<repo_owner>.github.io/<repo_name> (GitHub Pages default)
      • https://<your_domain> (GitHub Pages with CNAME file)
      • https://github.com/<repo_owner>/<repo_name>/blob/main (if you removed/don't want the documentation site)
    • {{docs_extension}} - Should be html if you use the documentation site, otherwise md
    • {{forum_url}} - URL to your forum for users to ask questions. It could be:
      • https://github.com/<repo_owner>/<repo_name>/discussions (if you enabled the discussions feature on your repo)
      • https://github.com/orgs/<repo_owner>/discussions (if you enabled the discussions feature at your org level)
      • https://<your_domain> (if you maintain a separate discussion forum, or a link to your community on Slack, Discord, etc.)

    For any decent-sized project, it is better to own your brand and use your own domain rather than GitHub links.

  2. Remove this README.md and move docs/README.md to the root

GitHub Actions

Some GitHub Actions bundled in this template require a personal access token (PAT). This can be sourced either from an app (recommended) or from a user.

From an app

  1. Create an app with the minimum permissions or add the following permissions to an existing app:

    • Contents: Read and write
    • Issues: Read and write
    • Pull requests: Read and write
  2. Set the GH_APP_ID and GH_APP_PRIVATE_KEY repository secrets.

  3. Install the app to your repository (click Install App on the left menu of the app page)

From a user

  1. Create a personal access token with the repo permissions.

  2. Set the GH_PERSONAL_TOKEN repository secret.

  3. Look into each file in .github/workflows:

    • Remove every step called Generate app token
    • Replace ${{ steps.generate_token.outputs.token }} with ${{ secrets.GH_PERSONAL_TOKEN }}

Dependency updates

You can pick between Renovate (recommended) or Dependabot for your dependency updates.

Dependabot won't keep your pre-commit hooks up to date as opposed to Renovate.

Renovate

  1. Install it
  2. Remove the file .github/dependabot.yaml

Dependabot

Just remove the file .github/renovate.json.

Tests

Unit tests

This template comes with two types of unit tests: static code analysis and runtime tests using various tools.

Unit tests are performed on the main module and on each example (eg. ./examples/minimal)

Integration tests

This template comes with two ways to test your module actually running terraform apply (and terraform destroy). Pick the one you prefer and delete the other one:

No actual terraform apply is run on the ./examples/* because the two ways above are more suited for actually testing the output.