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
256 views
in Technique[技术] by (71.8m points)

amazon web services - Terraform aws_dynamodb_table_item - insert multiline JSON into attribute

I have the following terraform config:

resource "aws_dynamodb_table_item" "my_table" {
  table_name = aws_dynamodb_table.my_table.name
  hash_key   = aws_dynamodb_table.my_table.hash_key

  item = <<ITEM
{
  "id": {"S": "nameAndCodes"},
  "data": {"S": "[
    {
      "code": "03",
      "displayName": "name1"
    },
    {
      "code": "04",
      "displayName": "name2"
    }
  ]"}
}
ITEM
}

When the plan stage executes I receive the error:

Error: Invalid format of "item": Decoding failed: invalid character '
' in string literal

The only way i can get this to work is to make the whole json a single line as follows:

"data": {"S": "[{"code": "03", "displayName": "name1"},{"code": "04", "displayName": "name2"}]"

This looks very ugly and difficult to manage.

Does anyone know how I can enter a multiline JSON inside a <<ITEM block?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
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

...