Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

terraform - Referring multiple global secondary indexes from output file

I have a table definition in one file. The table definition contains multiple secondary indexes definitions:

resource "aws_dynamodb_table" "recalculation_rules" {
  hash_key       = "code"
  name           = "TC-RecalculationRules-${terraform.workspace}"
  read_capacity  = 2
  write_capacity = 2

  attribute {
    name = "code"
    type = "S"
  }

  attribute {
    name = "nameHash"
    type = "S"
  }

  attribute {
    name = "pricesHash"
    type = "S"
  }

  global_secondary_index {
    hash_key        = "nameHash"
    name            = "RuleNameHashIndex"
    projection_type = "ALL"
    write_capacity  = 2
    read_capacity   = 2
  }

  global_secondary_index {
    hash_key        = "pricesHash"
    name            = "RulePricesHashIndex"
    projection_type = "ALL"
    write_capacity  = 2
    read_capacity   = 2
  }
}

In another file, I want to make a reference to these global secondary indexes names:

output "tc_recalculation_rules_table_global_secondary_by_name_index_name" {
  value = aws_dynamodb_table.recalculation_rules.global_secondary_index[0].name
}

output "tc_recalculation_rules_table_global_secondary_by_prices_index_name" {
  value = aws_dynamodb_table.recalculation_rules.global_secondary_index[1].name
}

However, it does not work for me:

 in output "tc_recalculation_rules_table_global_secondary_by_prices_index_name":
  38:   value = aws_dynamodb_table.recalculation_rules.global_secondary_index[1].name

Could you please help - how can I can refer to these indexes names in this case?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...