Terramate Documentation

repository·main·Indexed 25 days ago

https://github.com/terramate-io/terramate

An open-source orchestration and code generation engine for Infrastructure as Code (IaC) tools including Terraform, OpenTofu, Terragrunt, and Kubernetes. Terramate helps scale IaC by breaking down monolithic state files, reducing code duplication via HCL/JSON/YAML generation, and orchestrating complex workflows. It includes a CLI, a language server (terramate-ls), and the tgdeps tool for discovering Terragrunt module dependencies. Integration with Terramate Cloud provides additional features such as drift detection, observability, and asset management.

Tokens
22.4K
Snippets
18
Records
159
Agent score
85%

What's inside Terramate

  1. Overview of Terramate features

    main

    Terramate provides several core capabilities for managing IaC at scale:

    • Orchestration & Change Detection: Run commands (like terraform apply) in stacks with high concurrency. Use change detection to only execute stacks that have actual changes in Git or referenced modules.
    • Code Generation: Programmatically generate HCL, JSON, or YAML to keep configurations DRY.
    • Dependency Management: Manage dependencies between environments using output sharing and a graph-based engine.
    • Automation: Use pre-configured GitOps blueprints for GitHub Actions, GitLab CI/CD, BitBucket Pipelines, and Azure DevOps.
    • Cloud Features (Terramate Cloud): Adds drift management, misconfiguration detection (500+ policies), asset inventory, audit trails, and Slack integrations.
  2. Connect the Terramate CLI to Terramate Cloud

    main
    To access managed SaaS features such as observability, drift detection, and asset management, connect your local CLI to a Terramate Cloud account using the terramate cloud login command.
    terramate cloud login
  3. Onboard existing IaC projects to Terramate

    main

    Terramate can be added to existing infrastructure projects without refactoring. Depending on your current setup, follow the specific onboarding guide for your tool:

    • Terraform: For existing Terraform projects.
    • OpenTofu: For existing OpenTofu projects.
    • Terragrunt: For existing Terragrunt projects.
    • From Scratch: If you are starting a new project.
  4. Understand Bundle Promotion logic

    main

    Terramate supports promoting bundles from a source environment to a target environment. A bundle is considered 'promotable' if:

    1. The target environment has a PromoteFrom configuration pointing to a source environment.
    2. The bundle exists in the source environment.
    3. The bundle's alias does not already exist in the target environment.
    4. All bundle references (dependencies) required by the bundle are also available/present in the target environment's aliases.
  5. Configure inputs for a promoted bundle

    main

    After selecting a bundle to promote, the UI enters the ViewPromoteInput state. This allows you to provide specific values for the bundle's input definitions before saving them to the target environment.

    Key interactions in the input form:

    • Tab: Switch between different input sections (if the form uses two panels).
    • Esc:
      • If editing a multiline field or a sub-form: Exit the sub-form/edit mode.
      • If in the main form: Go back to the bundle selection list.
    • Save (via form confirmation): Validates the inputs, creates a PromoteChange, and applies the changes to the target environment's registry.
  6. Navigate and filter bundle reconfiguration in the UI

    main

    When using the Terramate interactive UI for reconfiguring bundles, you can navigate through available bundle instances and filter them by environment.

    • Up/Down Arrows: Move the selection cursor through the list of bundles.
    • Enter: Select a bundle to open its reconfiguration input form.
    • Escape:
      • If a filter is active: Reset the filter to show all bundles.
      • If no filter is active: Go back to the Overview view.

    Filtering

    • e: Cycle through available environment filters (e.g., specific environments or "Without Environment"). This allows you to quickly narrow down the list of bundles to those belonging to a specific context.
  7. Navigate and Edit Inputs in the CLI UI

    main

    When interacting with the Terramate CLI input forms, use the following patterns:

    • Editing an existing value: Navigate to the 'Inputs' or 'Attributes' panel at the bottom, select a row, and press Enter to open its editor.
    • Resetting a value: If you have modified a value, you can typically use del (delete) to reset it to its original state.
    • Handling Sub-forms: When editing nested objects, a new form will appear. Once finished, the sub-form is accepted or discarded to return to the parent object's attributes.
    • Confirming Changes: After filling all required inputs, look for inline buttons like [Confirm] [Cancel] or [Save] [Cancel] to commit your changes.
  8. Understand the Terramate CLI Inputs Form UI

    main

    The Terramate CLI uses an interactive terminal UI for managing inputs and attributes. The interface typically consists of two main panels:

    1. Top Panel (Active Input): Displays the current input being edited, including its prompt, description, and the active input widget (e.g., text field, checkbox, etc.). It also shows a counter of remaining inputs.
    2. Bottom Panel (Inputs/Attributes): A summary list of all inputs.
      • In Create mode, it shows all inputs, with a toggle to filter for required inputs only.
      • In Reconfiguring/Promoting mode, it shows the current state of attributes.

    Key UI Features:

    • Visual Cues: Required inputs are marked with *. Changed values are marked with ~ and show a diff (e.g., new ← old). Default-seeded values are dimmed. Immutable inputs are tagged as immutable.
    • Navigation: You can navigate between the active input and the completed list. In the completed list, you can select an item and press Enter to edit it.
    • Sub-forms: For complex object types, Terramate opens a nested sub-form. You can navigate these using standard form controls and return to the parent form upon acceptance or discard.