0
votes

I have one parameter in AWS System Manager, type of the value is string, but value has a dictionary structure:

Value:

{"key1": "value1","key2": "value2","key3": "value3"}

Now i'm trying to create this parameter using the Terraform. But i received an error, when trying to write this in aws_ssm_parameter resource:

resource "aws_ssm_parameter" "Paramet" {
  name = "/dev/parameter/new"
  description = "Sample config values"
  type = "String"
  value = "{key1" : "value1", "key2" : "value2", "key3" : "value3}"
}

Error:

$ terraform plan

Error: Missing newline after argument

on main.tf line 90, in resource "aws_ssm_parameter" "Paramet": 90: value = "{key1" : "value1", "key2" : "value2", "key3" : "value3}"

An argument definition must end with a newline.

This error is connected with syntax, but i can't understand, how to fix this correctly.

Please advice, how to input correctly this value in aws_ssm_parameter resource?

1
The error appears due to the " that are not escaped. To escape them you could add a backslash \ in front of each ". That being said, using heredoc as suggested in @tedsmitt' s answer is certainly more readableFalk Tandetzky

1 Answers

1
votes

You can use heredoc syntax to achieve this. The below should work for you

resource "aws_ssm_parameter" "Parameter" {
  name = "/dev/parameter/new"
  description = "Sample config values"
  type = "String"
  value = <<EOF
  {
      "key1" : "value1", 
      "key2" : "value2", 
      "key3" : "value3"
  }
  EOF
}