所属项目的计费帐户在"不存在"状态下被禁用



在确保执行了gcloud auth login并设置了正在使用的项目后,我正在尝试运行terraform init

启用了计费,这一定是因为否则我甚至无法为后端创建bucket,并且我可以从命令行向GCS bucketecho "hello" > test.txt && gsutil cp test.txt <bucket>/file文件。

一切似乎都正常。

然而,拥有这个文件

main.tf

terraform {
required_providers {
google = {
source = "hashicorp/google"
}
}
backend "gcs" {
bucket = "dev-00-tfbackend"
}
}

并且运行init命令,我得到以下错误:

$ terraform init
Initializing modules...
Initializing the backend...
Error loading state: Failed to open state file at gs://dev-00-tfbackend/default.tfstate: googleapi: got HTTP response code 403 with body: <?xml version='1.0' encoding='UTF-8'?><Error><Code>UserProjectAccountProblem</Code><Message>User project billing account not in good standing.</Message><Details>The billing account for the owning project is disabled in state absent</Details></Error>

错误消息:

<Error>
<Code>UserProjectAccountProblem</Code>
<Message>User project billing account not in good standing.</Message>
<Details>The billing account for the owning project is disabled in state absent</Details>
</Error>

我不知道这里的问题是什么。没有任何提示,也不可能是账单账户。

我可能不知怎么搞砸了我的本地配置,但正如所说,一切似乎都很好。


TRACE日志

$ TF_LOG=TRACE terraform init -reconfigure
2022-10-24T12:46:39.110+0200 [INFO]  Terraform version: 1.3.3
2022-10-24T12:46:39.110+0200 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0
2022-10-24T12:46:39.110+0200 [DEBUG] using github.com/hashicorp/hcl/v2 v2.14.1
2022-10-24T12:46:39.110+0200 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2
2022-10-24T12:46:39.110+0200 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
2022-10-24T12:46:39.110+0200 [DEBUG] using github.com/zclconf/go-cty v1.11.1
2022-10-24T12:46:39.110+0200 [INFO]  Go runtime version: go1.19.1
2022-10-24T12:46:39.110+0200 [INFO]  CLI args: []string{"terraform", "init", "-reconfigure"}
2022-10-24T12:46:39.110+0200 [TRACE] Stdout is a terminal of width 232
2022-10-24T12:46:39.110+0200 [TRACE] Stderr is a terminal of width 232
2022-10-24T12:46:39.110+0200 [TRACE] Stdin is a terminal
2022-10-24T12:46:39.110+0200 [DEBUG] Attempting to open CLI config file: /Users/sfalk/.terraformrc
2022-10-24T12:46:39.110+0200 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2022-10-24T12:46:39.111+0200 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2022-10-24T12:46:39.111+0200 [DEBUG] ignoring non-existing provider search directory /Users/sfalk/.terraform.d/plugins
2022-10-24T12:46:39.111+0200 [DEBUG] ignoring non-existing provider search directory /Users/sfalk/Library/Application Support/io.terraform/plugins
2022-10-24T12:46:39.111+0200 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2022-10-24T12:46:39.111+0200 [INFO]  CLI command args: []string{"init", "-reconfigure"}
Initializing modules...
2022-10-24T12:46:39.113+0200 [TRACE] ModuleInstaller: installing child modules for . into .terraform/modules
2022-10-24T12:46:39.114+0200 [DEBUG] Module installer: begin gcp-network
2022-10-24T12:46:39.116+0200 [TRACE] ModuleInstaller: Module installer: gcp-network 5.2.0 already installed in .terraform/modules/gcp-network
2022-10-24T12:46:39.116+0200 [DEBUG] Module installer: begin gcp-network.firewall_rules
2022-10-24T12:46:39.118+0200 [TRACE] ModuleInstaller: Module installer: gcp-network.firewall_rules <nil> already installed in .terraform/modules/gcp-network/modules/firewall-rules
2022-10-24T12:46:39.118+0200 [DEBUG] Module installer: begin gcp-network.routes
2022-10-24T12:46:39.118+0200 [TRACE] ModuleInstaller: Module installer: gcp-network.routes <nil> already installed in .terraform/modules/gcp-network/modules/routes
2022-10-24T12:46:39.118+0200 [DEBUG] Module installer: begin gcp-network.subnets
2022-10-24T12:46:39.119+0200 [TRACE] ModuleInstaller: Module installer: gcp-network.subnets <nil> already installed in .terraform/modules/gcp-network/modules/subnets
2022-10-24T12:46:39.119+0200 [DEBUG] Module installer: begin gcp-network.vpc
2022-10-24T12:46:39.120+0200 [TRACE] ModuleInstaller: Module installer: gcp-network.vpc <nil> already installed in .terraform/modules/gcp-network/modules/vpc
2022-10-24T12:46:39.120+0200 [TRACE] modsdir: writing modules manifest to .terraform/modules/modules.json
Initializing the backend...
2022-10-24T12:46:39.126+0200 [TRACE] Meta.Backend: built configuration for "gcs" backend with hash value 1444622975
2022-10-24T12:46:39.126+0200 [TRACE] Preserving existing state lineage "59095e3c-1db2-723e-ec73-8b49f7fc9428"
2022-10-24T12:46:39.126+0200 [TRACE] Preserving existing state lineage "59095e3c-1db2-723e-ec73-8b49f7fc9428"
2022-10-24T12:46:39.126+0200 [TRACE] Meta.Backend: working directory was previously initialized for "gcs" backend
2022-10-24T12:46:39.126+0200 [TRACE] Meta.Backend: moving from default local state only to "gcs" backend
2022-10-24T12:46:39.127+0200 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2022-10-24T12:46:39.127+0200 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/google v4.41.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/google/4.41.0/darwin_amd64
2022-10-24T12:46:39.127+0200 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/google-beta v4.41.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/google-beta/4.41.0/darwin_amd64
2022-10-24T12:46:39.128+0200 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/kubernetes v2.14.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/kubernetes/2.14.0/darwin_amd64
2022-10-24T12:46:39.128+0200 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/google/4.41.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/google 4.41.0
2022-10-24T12:46:39.128+0200 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/google-beta/4.41.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/google-beta 4.41.0
2022-10-24T12:46:39.128+0200 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/kubernetes/2.14.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/kubernetes 2.14.0
2022-10-24T12:46:39.313+0200 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2022-10-24T12:46:39.434+0200 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2022-10-24T12:46:39.627+0200 [DEBUG] checking for provisioner in "."
2022-10-24T12:46:39.628+0200 [DEBUG] checking for provisioner in "/usr/local/bin"
2022-10-24T12:46:39.628+0200 [TRACE] backend/local: state manager for workspace "default" will:
- read initial snapshot from terraform.tfstate
- write new snapshots to terraform.tfstate
- create any backup at terraform.tfstate.backup
2022-10-24T12:46:39.628+0200 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate
2022-10-24T12:46:39.628+0200 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay
2022-10-24T12:46:39.628+0200 [TRACE] statemgr.Filesystem: read nil snapshot
2022-10-24T12:46:39.628+0200 [TRACE] Meta.Backend: ignoring local "default" workspace because its state is empty
2022-10-24T12:46:40.038+0200 [TRACE] Meta.selectWorkspace: the currently selected workspace is present in the configured backend (default)
2022-10-24T12:46:40.038+0200 [TRACE] Preserving existing state lineage "59095e3c-1db2-723e-ec73-8b49f7fc9428"
2022-10-24T12:46:40.038+0200 [TRACE] Preserving existing state lineage "59095e3c-1db2-723e-ec73-8b49f7fc9428"
2022-10-24T12:46:40.038+0200 [TRACE] Preserving existing state lineage "59095e3c-1db2-723e-ec73-8b49f7fc9428"
Successfully configured the backend "gcs"! Terraform will automatically
use this backend unless the backend configuration changes.
2022-10-24T12:46:40.064+0200 [TRACE] Meta.Backend: instantiated backend of type *gcs.Backend
2022-10-24T12:46:40.065+0200 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2022-10-24T12:46:40.066+0200 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/google v4.41.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/google/4.41.0/darwin_amd64
2022-10-24T12:46:40.066+0200 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/google-beta v4.41.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/google-beta/4.41.0/darwin_amd64
2022-10-24T12:46:40.067+0200 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/kubernetes v2.14.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/kubernetes/2.14.0/darwin_amd64
2022-10-24T12:46:40.067+0200 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/google/4.41.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/google 4.41.0
2022-10-24T12:46:40.067+0200 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/google-beta/4.41.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/google-beta 4.41.0
2022-10-24T12:46:40.067+0200 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/kubernetes/2.14.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/kubernetes 2.14.0
2022-10-24T12:46:40.262+0200 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2022-10-24T12:46:40.447+0200 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2022-10-24T12:46:40.570+0200 [DEBUG] checking for provisioner in "."
2022-10-24T12:46:40.571+0200 [DEBUG] checking for provisioner in "/usr/local/bin"
2022-10-24T12:46:40.571+0200 [TRACE] Meta.Backend: backend *gcs.Backend does not support operations, so wrapping it in a local backend
Error loading state: Failed to open state file at gs://dev-
00-tfbackend-00/default.tfstate: googleapi: got HTTP response code 403 with body: <?xml version='1.0' encoding='UTF-8'?><Error><Code>UserProjectAccountProblem</Code><Message>User project billing account not in good standing.</Message><Details>The billing account for the owning project is disabled in state absent</Details></Error>

Terraform没有使用运行gcloud auth login时获得的凭据。它使用的是运行gcloud auth application-default login时生成的凭据。它还根据您在core/project下设置的内容在此处设置计费配额项目。我假设您运行过一次该命令,并配置了一个不再存在或没有计费帐户的配额项目。我建议再次运行gcloud auth application-default login,因为您已经配置了项目,现在应该将配额项目设置为您期望的项目。

相关内容

  • 没有找到相关文章

最新更新