I'm trying to use terraform and Linode's kubernetes cluster (LKE) in Github Actions, but I'm running into an issue when I try to run the plan
or apply
commands – they just hang. My guess is that because the terraform init
generates an output that the terraform plan
cannot access. But I'm not sure how to make that outcome available to the next step.
My github actions workflow file looks like this:
init-terraform:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: 'some-branch'
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan
- name: Terraform Apply
run: terraform apply -auto-approve
The init seems to work fine, but the plan just hangs. When I run this locally, the plan takes about 20 seconds.
My main.tf
file in the repo looks like this:
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "=1.16.0"
}
}
}
provider "linode" {
}
resource "linode_lke_cluster" "lke_cluster" {
label = "my-label"
k8s_version = "1.21"
region = "us-central"
pool {
type = "g6-standard-2"
count = 3
}
}
I have set the TERRAFORM_API_TOKEN
as a github secret and I set LINODE_TOKEN
as a terraform environment variable.
What am I missing that is causing the terraform call to hang?
Although, I'm not familiar with linode's provider, I have a strong hunch that you need to include
with:
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}
in each of your steps.