当项目包含 List AttributeValue 时,Terraform aws_dynamodb_table_item 资源失败
Terraform aws_dynamodb_table_item resource fails when item contains List AttributeValue
正在尝试创建 dynamodb table item resource which contains a DynamoDB List AttributeValue:
resource "aws_dynamodb_table_item" "job" {
table_name = var.some_table.id
hash_key = var.some_table.hash_key
item = <<ITEM
{
"partitionKey": {"S": "JOBID#1"},
"workloads": [{ "S" : "w1" }, { "S" : "w2" }]
}
ITEM
}
但失败:
Error: Invalid format of "item": Decoding failed: json: cannot unmarshal array into Go value of type dynamodb.AttributeValue
如果工作负载是字符串类型,则工作正常,例如{"S": "w1"}
但不是当一个列表。我究竟做错了什么?此资源是否能够创建列表属性值?
我正在使用 Terraform v1.0.0
应该是:
"partitionKey": {"S": "JOBID#1"},
"workloads": {"L": [{ "S" : "w1" }, { "S" : "w2" }]}
其中 L
用于列表。有关格式的信息是 here.
正在尝试创建 dynamodb table item resource which contains a DynamoDB List AttributeValue:
resource "aws_dynamodb_table_item" "job" {
table_name = var.some_table.id
hash_key = var.some_table.hash_key
item = <<ITEM
{
"partitionKey": {"S": "JOBID#1"},
"workloads": [{ "S" : "w1" }, { "S" : "w2" }]
}
ITEM
}
但失败:
Error: Invalid format of "item": Decoding failed: json: cannot unmarshal array into Go value of type dynamodb.AttributeValue
如果工作负载是字符串类型,则工作正常,例如{"S": "w1"}
但不是当一个列表。我究竟做错了什么?此资源是否能够创建列表属性值?
我正在使用 Terraform v1.0.0
应该是:
"partitionKey": {"S": "JOBID#1"},
"workloads": {"L": [{ "S" : "w1" }, { "S" : "w2" }]}
其中 L
用于列表。有关格式的信息是 here.