有一个奇怪的问题,我在运行TF代码时得到Error: Insufficient attribute blocks
...
dynamodb模块
locals {
my_name = "${var.prefix}-${var.env}-${var.name}"
my_env = "${var.prefix}-${var.env}"
}
resource "aws_dynamodb_table" "dynamodb-instance" {
name = "${local.my_name}"
read_capacity = 5
write_capacity = 5
hash_key = "${var.hash_key_name}"
attribute ["${var.attributes_list}"]
tags = {
Name = "${local.my_name}"
Environment = "${local.my_env}"
Terraform = "true"
}
}
variable "prefix" {}
variable "env" {}
variable "name" {}
variable "hash_key_name" {}
variable "attributes_list" {
type = "list"
}
dynamodb-tables模块
# The session dynamodb table.
module "dynamodb-session" {
source = "../dynamodb"
prefix = "${var.prefix}"
env = "${var.env}"
name = "session"
hash_key_name = "token"
attributes_list = [
{
name = "token"
type = "S"
},
]
}
# The users dynamodb table.
# NOTE: I should have named it "user" for consistency.
module "dynamodb-users" {
source = "../dynamodb"
prefix = "${var.prefix}"
env = "${var.env}"
name = "users"
hash_key_name = "email"
attributes_list = [
{
name = "email"
type = "S"
},
]
}
# The product-group dynamodb table.
module "dynamodb-product-group" {
source = "../dynamodb"
prefix = "${var.prefix}"
env = "${var.env}"
name = "product-group"
hash_key_name = "pgid"
attributes_list = [
{
name = "pgid"
type = "S"
},
]
}
# The product dynamodb table is a bit different because of secondary index.
# Let's create it directly here.
resource "aws_dynamodb_table" "product-dynamodb-instance" {
name = "${var.prefix}-${var.env}-product"
read_capacity = 5
write_capacity = 5
hash_key = "pid"
range_key = "pgid"
global_secondary_index {
name = "PGIndex"
hash_key = "pgid"
range_key = "pid"
write_capacity = 5
read_capacity = 5
projection_type = "INCLUDE"
non_key_attributes = ["price", "title"]
}
// attribute [[
// {
// name = "pid"
// type = "S"
// },
// {
// name = "pgid"
// type = "S"
// },
// ]]
tags = {
Name = "${var.prefix}-${var.env}-product"
Environment = "${var.prefix}-${var.env}"
Terraform = "true"
}
}
variable "prefix" {}
variable "env" {}
variable "region" {}
不确定发生了什么事