当我在12.24版本中运行terraform计划时,我得到了错误:不支持的参数。
Error: Unsupported argument
on .terraform/modules/app/main.tf line 261, in resource "aws_db_instance" "db_instance":
261: timeouts = {
An argument named "timeouts" is not expected here. Did you mean to define a
block of type "timeouts"?
这是tf文件中的代码:
timeouts = {
create = "${var.db_instance_create_timeout}"
update = "${var.db_instance_update_timeout}"
delete = "${var.db_instance_delete_timeout}"
}
我不知道如何纠正这个错误。
- 通过删除"="超时后
我也遇到了更多的错误,需要解决方案:
Error: Unsupported argument
on .terraform/modules/rds/main.tf line 150, in resource "aws_db_parameter_group" "db_parameter_group":
150: parameter = concat(var.parameters, local.parameters[local.parameter_lookup])
An argument named "parameter" is not expected here. Did you mean to define a
block of type "parameter"?
tf文件中的代码:
parameter = concat(var.parameters, local.parameters[local.parameter_lookup])
如何解决这个问题?
我正在从github复制为我工作的解决方案,并将其归功于hashicorp成员bflad:
在Terraform0.12(或更高版本)中,配置语言解析器对参数和配置块之间的区别更严格。此错误:
An argument named "XXX" is not expected here. Did you mean to
define a block of type "XXX"?
通常意味着需要从参数分配中删除=(等号),以便将其正确解析为配置块,例如
root_block_device {
HCL语法中的这种区别可能看起来微不足道,但在本质上,这种更严格的类型检查允许与JSON语法保持一致。有关此更改的更多信息,请参阅Terraform 0.12升级指南。说到这里,在该指南中,它确实指向了有用的terraform 0.12upgrade命令,当从terraform 0.11升级时,该命令应该会自动修复terraform配置中的此类问题。
错误
一个名为"secret_environment_variables";此处不应出现。你的意思是定义一个类型为";secret_environment_variables";?
问题
main.tf
resource "google_cloudfunctions_function" "this" {
secret_environment_variables = var.secret_environment_variables
}
variables.tf
variable "secret_environment_variables" {
type = any
default = {}
description = "Secret environment variables configuration."
}
解决方案
resource "google_cloudfunctions_function" "this" {
secret_environment_variables {
key = var.secret_environment_variables_key
secret = var.secret_environment_variables_secret
version = var.secret_environment_variables_version
}
}
variable "secret_environment_variables_key" {
type = string
default = null
nullable = true
description = "Name of the environment variable."
}
variable "secret_environment_variables_secret" {
type = string
default = null
nullable = true
description = "ID of the secret in secret manager (not the full resource name)."
}
variable "secret_environment_variables_version" {
type = string
default = null
nullable = true
description = "Version of the secret (version number or the string `latest`). It is recommended to use a numeric version for secret environment variables as any updates to the secret value is not reflected until new clones start."
}