If you need to manage your workspaces and execute Jobs from an external CI/CD tool you can use the Terrakube API, however a simple approach is to use the existing integrations:
CI/CD tool | Integration |
---|---|
For more information about this pipe please refer to the following .
Github
Bitbucket
Azure DevOps
Azure DevOps extension is in development
LOGIN_ENDPOINT |
TERRAKUBE_TENANT_ID (*) | Azure AD Application tenant ID |
TERRAKUBE_APPLICATION_ID (*) | Azure AD Application tenant ID |
TERRAKUBE_APPLICATION_SECRET (*) | Azure AD Application tenant ID |
TERRAKUBE_APPLICATION_SCOPE | Default value: api://Terrakube/.default |
TERRAKUBE_ORGANIZATION (*) | Terrakube organization name |
TERRAKUBE_WORKSPACE (*) | Terrakube workspace name |
TERRAKUBE_TEMPLATE (*) | Terrakube template name |
TERRAKUBE_ENDPOINT (*) | Terrakbue api endpoint |
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
Add the following snippet to the script section of your github actions file:
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.
To run a terraform apply using Terrakube templates use the following example:
File: .github/workflows/push_main.yml
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.
(*) = required variable.
Create a file called "terrakube.json" and include the terraform version that will be used for the job execution
To build the github action in your local machine use the following.
Default values:
Variable | Usage |
---|
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 |