Welcome to OStack Knowledge Sharing 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...