我正在尝试在gcp中使用terraform cloud。为此,我有以下提供程序配置
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.89.0"
}
}
}
provider "google" {
region = local.region
project = local.project
credentials =
}按照https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#credentials-1,我已经创建了环境变量GOOGLE_CREDENTIALS并设置了下载的凭证文件。
现在,当我尝试使用github操作运行工作流时,我得到以下错误

这是我的gihub工作流文件的样子
name: 'event profile api deploy pipeline'
on:
workflow_dispatch:
branches:
- main
pull_request:
jobs:
terraform:
name: 'Terraform-deploy'
runs-on: ubuntu-latest
environment: dev
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
working-directory: ./terraform
run: terraform init
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
working-directory: ./terraform
run: terraform fmt -check
# Generates an execution plan for Terraform
- name: Terraform Plan
working-directory: ./terraform
run: terraform plan你知道这里会出什么问题吗?
发布于 2021-11-04 22:05:38
弄清楚了,我没有在provider部分中使用backend部分。下面给出的是使用Terraform云的工作提供程序版本
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.89.0"
}
}
backend "remote" {
organization = "org"
workspaces {
name = "namespace"
}
}
}
provider "google" {
region = local.region
project = local.project
}https://stackoverflow.com/questions/69820011
复制相似问题