title: Terraform AWS SSM Parameter with multiple values
body: <p>I need to store multiple values related to the same environment in the SSM parameter store. What would be the best practice? Storing the values with the individual parameter? or storing everything in a single parameter?</p>
  <p>When am storing it individually, it's pretty straight forward to get the value using the following terraform code.</p>
  <p>SSM parameter <code>foo</code></p>
  <pre><code>bar
  </code></pre>
  <pre><code>data &quot;aws_ssm_parameter&quot; &quot;ssm_parameters&quot; {
    for_each = var.ssm_parameters
    name     = each.key
  }
  
  output &quot;ssm_parameters&quot; {
    value = tolist([
      for ssm_parameter in data.aws_ssm_parameter.ssm_parameters : ssm_parameter.value
    ])
  }
  </code></pre>
  <p>Output:</p>
  <pre><code>➜  aws_ssm git:(add/ssm_resources) ✗ terraform apply -var-file=&quot;test.tfvars&quot;
  data.aws_ssm_parameter.ssm_parameters[&quot;foo&quot;]: Refreshing state...
  
  Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
  
  Outputs:
  
  ssm_parameters = [
    &quot;bar&quot;,
  ]
  </code></pre>
  <p>When am storing all values in a single parameter. Is there a way to get the values based on the particular key? For example, if I store the values something like below, is there a way to get only <code>server2</code> value? or <code>server1</code> <code>eth1</code> value?</p>
  <p>SSM parameter <code>foo</code>:</p>
  <pre><code>[
    {
      server1_eth0 = “server_ip1&quot;
      server1_eth1 = “server_ip2&quot;
      server2 = “server2_ip&quot;
      server3 = “server3_ip&quot;
    }
  ]
  </code></pre>