{"id":29876760,"url":"https://github.com/infinitaslearning/ilpt-terrakube-extensions","last_synced_at":"2025-07-31T04:21:30.821Z","repository":{"id":306408820,"uuid":"1026060082","full_name":"infinitaslearning/ilpt-terrakube-extensions","owner":"infinitaslearning","description":"Policy and workflow extensions for Terrakube","archived":false,"fork":false,"pushed_at":"2025-07-25T12:49:45.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-25T15:34:58.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infinitaslearning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-25T08:41:46.000Z","updated_at":"2025-07-25T12:49:49.000Z","dependencies_parsed_at":"2025-07-25T15:37:09.301Z","dependency_job_id":"14e7fcc4-9d53-4242-9523-3cc8545f767e","html_url":"https://github.com/infinitaslearning/ilpt-terrakube-extensions","commit_stats":null,"previous_names":["infinitaslearning/ilpt-terrakube-extensions"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/infinitaslearning/ilpt-terrakube-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitaslearning%2Filpt-terrakube-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitaslearning%2Filpt-terrakube-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitaslearning%2Filpt-terrakube-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitaslearning%2Filpt-terrakube-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infinitaslearning","download_url":"https://codeload.github.com/infinitaslearning/ilpt-terrakube-extensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infinitaslearning%2Filpt-terrakube-extensions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267987306,"owners_count":24176774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-31T04:21:25.551Z","updated_at":"2025-07-31T04:21:30.797Z","avatar_url":"https://github.com/infinitaslearning.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terrakube Extensions\nTerrakube support to customize the job workflow for an specific workspace using external tools. \n\nThe workflow is built with the **Terrakube Configuration Language** using a ***YAML*** file\n\nThe standard job workflow looks like the following example:\n```yaml\nflow:\n  - type: \"terraformPlan\"\n    step: 100\n  - type: \"terraformApply\"\n    step: 200\n```\n\nIf you want to customize the job workflow we can add ***commands*** using ***Groovy*** or ***Bash*** and execute user defined actions.\n```yaml\nflow:\n  - type: \"terraformPlan\"\n    step: 100\n    commands:\n      - runtime: \"GROOVY\"\n        priority: 100\n        before: true\n        script: |\n          \n          import TerraTag\n\n          new TerraTag().downloadTerraTag(\"$workingDirectory\", \"0.1.29\", \"darwin\", \"amd64\")\n          \"TerraTag Download Compledted...\"\n      - runtime: \"BASH\"\n        priority: 200\n        before: true\n        script: |\n          echo $PATH\n          helloWorld.sh\n          terratag.sh\n  - type: \"terraformApply\"\n    step: 300\n```\n\nAt runtime while executing a job workspace the groovy clases and bash scripts are loaded inside the job context so you can execute user defined actions.\n\n## Bash Script Injection\n\nDuring runtime all the bash scripts inside the folder ***bash*** for this repository are loaded inside the job context, so we can call different scripts like the following example\n\n```yaml\nflow:\n  - type: \"customScripts\"\n    step: 100\n    commands:\n      - runtime: \"BASH\"\n        priority: 200\n        before: true\n        script: |\n          helloWorld.sh\n          terratag.sh\n  - type: \"terraformApply\"\n    step: 300\n```\n\n\u003e All bash scripts should end with extension ***\".sh\"***\n\n## Groovy Classes Injection\n\nDuring runtime all the groovy classes are loaded inside the job context, we can import it using an import statement like the following example:\n\n```yaml\nflow:\n  - type: \"terraformPlan\"\n    step: 100\n    commands:\n      - runtime: \"GROOVY\"\n        priority: 100\n        before: true\n        script: |\n          import TerraTag\n          new TerraTag().loadTool(\n            \"$workingDirectory\",\n            \"$bashToolsDirectory\",\n            \"0.1.30\")\n          \"Terratag download completed\"\n```\n\n\u003e All clases should end with extension ***\".groovy\"***\n\n## Field Injection\n\nBy default terrakube will inject the following values inside the job context while running the user defined actions.\n\n- bashToolsDirectory\n- terrakubeToolsRepository\n- workingDirectory\n- organizationId\n- workspaceId\n- jobId\n- stepId\n- terraformVersion\n- source\n- branch\n- vcsType\n- accessToken\n- terraformOutput\n- terrakubeApi\n- terrakubeToken\n- workspace variables\n- workspace environment variables \n\nif you are using the ***Bash*** runtime this fields will be available as environment variables, for ***Groovy*** this values are injecte as bindings that can be access using the groovy syntax with ***$*** character\n\n## Advance example\n\nExample 1: Writing all the custom logic in groovy and bash with fields injection\n```yaml\nflow:\n  - type: \"terraformPlan\"\n    step: 100\n    commands:\n      - runtime: \"GROOVY\"\n        priority: 100\n        before: true\n        script: |\n          @Grapes([\n            @Grab('commons-io:commons-io:2.8.0'),\n            @Grab('org.apache.commons:commons-compress:1.21'),\n          ])\n\n          import org.apache.commons.io.FileUtils\n          \n          class TerraTagDownloader {\n            def downloadTerraTag(workingDirectory, version, os, arch) {\n              String terraTagFile = \"terratag_${version}_${os}_${arch}.tar.gz\"\n              String terraTagURL = \"https://github.com/env0/terratag/releases/download/v${version}/${terraTagFile}\"\n              println \"Downloading $terraTagURL\"\n              FileUtils.copyURLToFile(new URL(terraTagURL), new File(\"${workingDirectory}/${terraTagFile}\"))\n            }\n          } \n          new TerraTagDownloader().downloadTerraTag(\"$workingDirectory\", \"0.1.29\", \"darwin\", \"amd64\")\n          \"TerraTag Download Compledted...\"\n      - runtime: \"BASH\"\n        priority: 200\n        before: true\n        script: |\n          cd $workingDirectory;\n          tar -xvf terratag_0.1.29_darwin_amd64.tar.gz;\n          chmod +x terratag;\n          ./terratag -tags=\"{\\\"environment_id\\\": \\\"development\\\"}\"\n  - type: \"terraformApply\"\n    step: 300\n  - type: \"terraformDestroy\"\n    step: 400\n```\n\nExample 2: Reusing exiting Terrakube extension to simplify the flow\n```yaml\nflow:\n- type: \"terraformPlan\"\n  step: 100\n  commands:\n    - runtime: \"GROOVY\"\n      priority: 100\n      before: true\n      script: |\n        import TerraTag\n        new TerraTag().loadTool(\n          \"$workingDirectory\",\n          \"$bashToolsDirectory\",\n          \"0.1.30\")\n        \"Terratag download completed\"\n    - runtime: \"BASH\"\n      priority: 200\n      before: true\n      script: |\n        cd $workingDirectory\n        terratag -tags=\"{\\\"environment_id\\\": \\\"development\\\"}\"\n- type: \"terraformApply\"\n  step: 300\n```\n\nExample 3: Handle terraform output after terraform apply \n```yaml\nflow:\n  - type: \"terraformPlan\"\n    step: 100\n    commands:\n      - runtime: \"GROOVY\"\n        priority: 100\n        before: true\n        script: |\n          import TerraTag\n          new TerraTag().loadTool(\n            \"$workingDirectory\",\n            \"$bashToolsDirectory\",\n            \"0.1.30\")\n          \"Terratag download completed\"\n      - runtime: \"BASH\"\n        priority: 200\n        before: true\n        script: |\n          cd $workingDirectory\n          terratag -tags=\"{\\\"environment_id\\\": \\\"development\\\"}\"\n  - type: \"terraformApply\"\n    step: 200\n    commands:\n      - runtime: \"GROOVY\"\n        priority: 100\n        after: true\n        script: |\n          import groovy.json.JsonSlurper\n\n          def jsonSlurper = new JsonSlurper()\n          def terraformOutput = jsonSlurper.parseText(\"$terraformOutputJson\")\n\n          terrakubeOutput \u003c\u003c \"This is the name of the RG ${terraformOutput.rg_name.value}\"\n  - type: \"terraformDestroy\"\n    step: 400\n```\n\nExample 4: Handle approvals inside jobs\n```yaml\nflow:\n- type: \"terraformPlan\"\n  step: 100\n  commands:\n    - runtime: \"GROOVY\"\n      priority: 100\n      before: true\n      script: |\n        import TerraTag\n        new TerraTag().loadTool(\n          \"$workingDirectory\",\n          \"$bashToolsDirectory\",\n          \"0.1.30\")\n        \"Terratag download completed\"\n    - runtime: \"BASH\"\n      priority: 200\n      before: true\n      script: |\n        cd $workingDirectory\n        terratag -tags=\"{\\\"environment_id\\\": \\\"development\\\"}\"\n- type: \"approval\"\n  step: 150\n  team: \"AZB_ADMIN\"\n- type: \"terraformApply\"\n  step: 200\n  commands:\n    - runtime: \"GROOVY\"\n      priority: 100\n      after: true\n      script: |\n        import groovy.json.JsonSlurper\n        \n        def jsonSlurper = new JsonSlurper()\n        def terraformOutput = jsonSlurper.parseText(\"$terraformOutputJson\")\n\n        terrakubeOutput \u003c\u003c \"This is the name of the RG ${terraformOutput.rg_name.value}\"\n- type: \"approval\"\n  step: 250\n  team: \"AZB_ADMIN\"\n- type: \"terraformDestroy\"\n  step: 300\n```\n\n## Supported External tools\n\nTerrakube extension support the following tools:\n\n- Terratag (Groovy Extension)\n- Infracost (Groovy Extension)\n- Terrascan (Groovy Extension)\n- SendGrid (Groovy Extension)\n- Snyk (Groovy Extension)\n- Slack (Groovy Extension)\n- Open Policy Agent (Groovy Extension)\n\n## Extenal Tools in development\n\n- Teams\n\n## Contribute\n\nIf you want to integrate terrakube extension with other tools feel free to create a fork and send a pull request to this repository\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitaslearning%2Filpt-terrakube-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfinitaslearning%2Filpt-terrakube-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitaslearning%2Filpt-terrakube-extensions/lists"}