Jon*_*uys 3 terraform devops infrastructure-as-code terraform0.12+
我正在使用 Terraform 进行 AWS 多账户设置。我有一个主账户,它创建了几个子账户,在子账户中我引用了主账户的远程状态来检索输出值。
terraform plan测试 main.tf 中此配置的命令失败:
terraform {
required_version = ">= 0.12.0"
backend "s3" {
bucket = "bucketname"
key = "statekey.tfstate"
region = "us-east-1"
}
}
provider "aws" {
region = "us-east-1"
version = "~> 2.7"
}
data "aws_region" "current" {}
data "terraform_remote_state" "common" {
backend = "s3"
config {
bucket = "anotherbucket"
key = "master.tfstate"
}
}
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
? test terraform plan
Error: Unsupported block type
on main.tf line 20, in data "terraform_remote_state" "common":
20: config {
Blocks of type "config" are not expected here. Did you mean to define argument
"config"? If so, use the equals sign to assign it a value.
Run Code Online (Sandbox Code Playgroud)
从我从文档中可以看出,这应该有效……我做错了什么?
? test terraform -v
Terraform v0.12.2
+ provider.aws v2.14.0
Run Code Online (Sandbox Code Playgroud)
升级到 0.12.x 后好像没有更新相关文档
作为错误提示,在=后面添加config
data "terraform_remote_state" "common" {
backend = "s3"
config = {
bucket = "anotherbucket"
key = "master.tfstate"
}
}
Run Code Online (Sandbox Code Playgroud)
如果问题解决了,建议提个 PR 来更新文档,这样其他人就可以避免同样的问题了。
| 归档时间: |
|
| 查看次数: |
1174 次 |
| 最近记录: |