Terrakube
2.20.0
2.20.0
  • Introduction
  • Updates
  • Getting started
    • 📐Architecture
    • 🔐Security
    • 🚀Getting Started
    • 💿Docker Images
    • 🌐Docker Compose
    • 🚗Docker Compose + Traefik
    • 📥Deployment
      • 🔨Helm Chart
      • 🚀Minikube
      • 🔑Minikube + HTTPS
      • ✈️Ingress Configuration
      • 🔐User Authentication (DEX)
      • 💾Storage backend
        • Azure Storage Account
        • Amazon Cloud Storage
        • Google Cloud Storage
        • Minio (S3 compatible)
      • 🛰️Database Backend
        • SQL Azure
        • PostgreSQL
        • MySQL
        • H2
      • 🔐Custom CA Certs
      • ⚙️Custom Terraform CLI Builds
      • 👮Self-Hosted Agents
      • 📶Proxy Configuration
      • 🛡️Token Security
      • 🚦Open Telemetry
    • 🤵User Management
      • Azure Active Directory
      • Google Cloud Identity
      • Amazon Cognito
      • Github
  • 📓User Guide
    • Organizations
      • Creating an Organization
      • Global Variables
      • Team Management
      • API Tokens
      • Templates
        • Default Templates
        • Persistent Context
        • Import Templates
        • UI Templates
        • Filter global variables in jobs
        • Template Scheduling in Jobs
      • Tags
    • VCS Providers
      • Github
      • Github Enterprise
      • GitLab
      • Gitlab EE and CE
      • Bitbucket
      • Azure DevOps
      • SSH
    • Workspaces
      • Overview
      • Creating Workspaces
      • Terraform State
      • Share Workspace State
      • Variables
      • Workspace scheduler
      • API-driven Workflow
      • CLI-driven Workflow
      • Ephemeral Workspaces
    • Private Registry
      • Publishing Private Modules
      • Using Private Modules
    • Policy Enforcement (OPA)
    • Cost Estimation
    • Drift Detection
    • CI/CD Integration
      • Github Actions
      • Bitbucket
    • Terrakube CLI
      • Getting started
      • Installation
      • Commands
        • terrakube login
        • terrakube logout
        • terrakube organization
          • organization list
          • organization create
          • organization update
          • organization delete
        • terrakube team
          • team list
          • team create
          • team update
          • team delete
        • terrakube workspace
          • workspace list
          • workspace create
          • workspace update
          • workspace delete
          • workspace variable
            • variable list
        • terrakube variable
          • variable update
          • variable delete
          • variable create
        • terrakube job
          • job list
          • job create
        • terrakube module
          • module list
          • module create
          • module update
          • module delete
    • Reference
      • Executor
        • Terraform Execution Flow
        • Terraform Versions
    • Migrating to Terrakube
  • 🎓Learn
    • What is Terrakube
      • Section Overview
      • Terraform in a Nutshell
      • Terraform Challenges at Enterprise Level
      • Introducing Terrakube
      • Summary and Up Next
    • Deploying using Terrakube
  • 📖API
    • 🌟Getting started
    • ⚙️Methods
      • Globalvar
      • Organization
      • Teams
      • Workspace
      • Variables
      • History
      • Jobs
      • Template
      • Schedule
      • Step
      • Module
      • Vcs
      • Provider
      • Personal Access Token
      • Team API Tokens
      • SSH Key
      • Agent
Powered by GitBook
On this page
  1. User Guide
  2. Reference
  3. Executor

Terraform Execution Flow

PreviousExecutorNextTerraform Versions

Last updated 1 year ago

When running a job inside the executor component the following logic is used:

  • A folder to execute the job will be created using the organization id and workspace id:

    • /home/cnb/.terraform-spring-boot/executor/{{ORGANIZATION_ID}}//{{WORKSPACE_ID}}

  • The executor component will initially clone the workspace to the following folder:

    • /home/cnb/.terraform-spring-boot/executor/{{ORGANIZATION_ID}}//{{WORKSPACE_ID}}/.originRepository

  • All the files inside ".originalRepository" are moved to {{ORGANIZATION_ID}}//{{WORKSPACE_ID}} folder from previous step.

  • Te executor component will create the extension folders where you can store BASH or GROOVY extensions:

    • /home/cnb/.terraform-spring-boot/executor/{{ORGANIZATION_ID}}/{{WORKSPACE_ID}}/.terrakube/toolsRepository

      • By default it will clone the repository "", this can be change by using TerrakubeToolsRepository and TerrakubeToolsBranch environment variables.

    • The executor component will scan the extension folder and will add all the "sh" files to the linux path when using BASH commands.

    • The executor component will scan the extension folder and will add all the ".groovy" files as Groovy dependencies dynamical when using GROOVY commands.

      • When using GROOVY extension to download an external tools, the extension can use the following folder /home/cnb/.terraform-spring-boot/executor/{{ORGANIZATION_ID}}/{{WORKSPACE_ID}}/.terrakube/tools all the folder inside the "tools" folder are also included in the linux execution PATH

    • By default the executor component will also include all the "sh" from the imported workspace files

  • Once the executor component has all the necesarry information it will execute the selected template flow for the job.

  • When the job execution is completed the current {{ORGANIZATION_ID}}/{{WORKSPACE_ID}} is deleted.

An example of how to import external tools can be found in the Terratag Groovy extension

This extension download the terratag binary and expose the binary to be used inside the linux PATH when using BASH commands.

When using the following template:

flow:
  - type: "terraformPlan"
    name: "Plan"
    step: 100
    commands:
      - runtime: "GROOVY"
        priority: 100
        before: true
        script: |
          import TerraTag
          new TerraTag().loadTool(
            "$workingDirectory",
            "$bashToolsDirectory",
            "0.1.30")
          "Terratag download completed"
      - runtime: "BASH"
        priority: 200
        before: true
        script: |
          helloWorld.sh
  | - .originRepository
  |  | - .git
  |  |  | - refs
  |  |  |  | - heads
  |  |  |  | - tags
  |  |  | - logs
  |  |  |  | - refs
  |  |  |  |  | - heads
  |  |  | - objects
  |  |  |  | - info
  |  |  |  | - pack
  |  |  | - branches
  |  |  | - hooks
  |  | - getting-started
  |  | - local
  | - .git
  |  | - refs
  |  |  | - heads
  |  |  | - tags
  |  | - logs
  |  |  | - refs
  |  |  |  | - heads
  |  | - objects
  |  |  | - info
  |  |  | - pack
  |  | - branches
  |  | - hooks
  | - getting-started
  | - local
  | - .terraform
  |  | - providers
  |  |  | - registry.terraform.io
  |  |  |  | - hashicorp
  |  |  |  |  | - null
  |  |  |  |  |  | - 3.2.1
  |  |  |  |  |  |  | - linux_amd64
  |  |  |  |  | - time
  |  |  |  |  |  | - 0.9.1
  |  |  |  |  |  |  | - linux_amd64
  | - .terrakube
  |  | - tools
  |  |  | - terratag
  |  | - toolsRepository
  |  |  | - .git
  |  |  |  | - refs
  |  |  |  |  | - heads
  |  |  |  |  | - tags
  |  |  |  |  | - remotes
  |  |  |  |  |  | - origin
  |  |  |  | - logs
  |  |  |  |  | - refs
  |  |  |  |  |  | - heads
  |  |  |  | - objects
  |  |  |  |  | - info
  |  |  |  |  | - pack
  |  |  |  | - branches
  |  |  |  | - hooks
  |  |  | - bash
  |  |  |  | - helloWorld
  |  |  |  | - terratag
  |  |  | - groovy
  |  |  |  | - Context
  |  |  |  | - Infracost
  |  |  |  | - Opa
  |  |  |  | - Sendgrid
  |  |  |  | - SlackApp
  |  |  |  | - Snyk
  |  |  |  | - TerraTag
  |  |  |  | - Terrascan
  |  |  | - policy
  |  |  | - templates
  |  |  |  | - terratag

The following directory structure will be generating when using a workspace with the workspace with ""

📓
https://github.com/AzBuilder/terrakube-extensions
https://github.com/AzBuilder/terrakube-extensions/tree/main/groovy/TerraTag
https://github.com/AzBuilder/terrakube-docker-compose