Github Actions
Integrate Terrakube with GitHub Actions is easy and you can handle your workspace from GitHub.
The GIT repository will represent a Terrakube Organization and each folder inside the repository will be a new workspace.
There is an example available in the following link
Configuration
Add the following snippet to the script section of your github actions file:
Pull Request example
To run a terraform plan using Terrakube templates use the following example:
File: .github/workflows/pull_request.yml
A new workspace will be created for each folder with the file "terrakube.json". For each PR only new folders or folders that has been updated will be evaluated inside Terrakube.
Push Main branch
To run a terraform apply using Terrakube templates use the following example:
File: .github/workflows/push_main.yml
Terrakube Variables
To define terrakube variables to connect to cloud providers it is recommended to use Global Variables inside the organization using the UI. Terraform variables could be define inside a terraform.tfvars inside each folder or you can define inside the Terrakube UI after the workspace creation.
GitHub Action Inputs
TERRAKUBE_TOKEN (*)
Terrakube Personal Access Token
TERRAKUBE_TEMPLATE (*)
Terrakube template name
TERRAKUBE_ENDPOINT (*)
Terrakbue api endpoint
TERRAKUBE_ORGANIZATION (*)
Terrakbue organization
TERRAKUBE_BRANCH (*)
Github Branch when running a job
TERRAKUBE_SSH_KEY_NAME (*)
ssh key name define in the terrakube organization to connect to private repositories
GITHUB_TOKEN (*)
Github Token
SHOW_OUTPUT (*)
Show terrakube logs inside PR comments
(*) = required variable.
Terraform Version Configuration
Create a file called "terrakube.json" and include the terraform version that will be used for the job execution
Build GitHub Action
To build the github action in your local machine use the following.
Last updated