【发布时间】:2021-09-25 15:30:40
【问题描述】:
我正在尝试在 Github Actions 中使用 terraform 和 Linode 的 kubernetes 集群 (LKE),但是当我尝试运行 plan 或 apply 命令时遇到了问题 - 它们只是挂起。我的猜测是因为terraform init 生成了terraform plan 无法访问的输出。但我不确定如何使该结果可用于下一步。
我的 github 操作工作流文件如下所示:
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
初始化似乎工作正常,但计划只是挂起。当我在本地运行时,该计划大约需要 20 秒。
我在 repo 中的 main.tf 文件如下所示:
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
}
}
我已将 TERRAFORM_API_TOKEN 设置为 github 机密,并将 LINODE_TOKEN 设置为 terraform 环境变量。
我错过了什么导致 terraform 调用挂起?
【问题讨论】:
标签: kubernetes terraform github-actions linode