我正在按照本文档迁移本地状态以与 Terraform Cloud 集成。
https://learn.hashicorp.com/tutorials/terraform/cloud-migrate
这很简单,我只需要复制这段代码:
terraform {
required_version = ">= 1.1.0"
required_providers {
random = {
source = "hashicorp/random"
version = "3.0.1"
}
}
cloud {
organization = "<ORG_NAME>"
workspaces {
name = "Example-Workspace"
}
}
}
问题是我下面的代码与上面的代码相同
terraform {
required_version = ">= 0.14.9"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
cloud {
organization = "ORG"
workspaces {
name = "ORG_WORKSPACE"
}
}
}
但它返回一个错误:
Blocks of type "cloud" are not expected here.
一些注意事项:
- 我将代码放在一个名为
providers.tf
. - 我已经完成了一些其他代码并做了一个
terraform apply
,从而返回 tfstate. terraform login
我使用我的凭据登录到 Terraform Cloud 。- 当我尝试 terraform init 时,会发生错误。
任何帮助将非常感激。谢谢!