Skip to content

Indexer

The Terrateam code indexer is a feature that automatically generates parts of the Terrateam configuration by analyzing the repository structure and Terraform code. This reduces the amount of manual configuration needed and helps ensure that the correct directories are executed during plan and apply operations.

Configuration

The indexer is configured in the .terrateam/config.yml file under the indexer key. Here’s the default configuration:

indexer:
enabled: false

Enabled

The enabled key is used to specify whether the indexer is enabled or not.

KeyTypeDescription
enabledBooleanSpecifies whether the indexer is enabled. Default is false.

Functionality

When the indexer is enabled, it creates a map of the repository, including:

  • Terraform modules and the directories that reference those modules
  • Symbolic links in the repository

Terrateam uses this information to determine which directories should be executed during plan and apply operations.

Modules

If a directory is referenced with a module block in the Terraform code, the indexer automatically determines that:

  • The module directory should not be run if it changes
  • The directories referencing the module should be run if the module changes

This ensures that the appropriate directories are executed based on the module dependencies in the Terraform code.

If a symbolic link is present in the repository, the indexer treats the symlink as the actual file or directory it references. This allows Terrateam to correctly handle symlinked files and directories during plan and apply operations.

Usage

To enable the indexer, add the following configuration to your .terrateam/config.yml file:

indexer:
enabled: true

When the indexer is enabled, an indexing step will automatically be executed on a change if there is no index for that commit hash already. You can also manually trigger the indexer by commenting terrateam index in a pull request. This can be useful if you want to force a re-indexing of the repository. To see the parts of the Terrateam configuration that have been automatically generated after an indexing run, comment terrateam repo-config in the pull request. This will display the automatically generated configuration, allowing you to review and verify the changes.

Considerations

When using the indexer, keep the following in mind:

  • The indexer runs automatically on changes when enabled, but you can also trigger it manually using the terrateam index command in a pull request.
  • Reviewing the automatically generated configuration using the terrateam repo-config command can help you understand how Terrateam is interpreting your repository structure and Terraform code.
We use cookies and similar technologies to provide certain features, enhance the user experience and deliver content that is relevant to your interests. Depending on their purpose, analysis and marketing cookies may be used in addition to technically necessary cookies. By clicking on "Agree and continue", you declare your consent to the use of the aforementioned cookies. Here you can make detailed settings or revoke your consent (in part if necessary) with effect for the future. For further information, please refer to our Privacy Policy .