title: How combine multiple output objects into a single object with jq
body: <p>I'm trying to parse the output of a terraform state file.</p>
  
  <pre><code>{
      "version": 3,
      "terraform_version": "0.9.3",
      "serial": 0,
      "lineage": "ae1f2572-8fa6-4977-be73-3deac7529eff",
      "modules": [
          {
              "path": [
                  "root"
              ],
              "outputs": {
                  "elb_dns_name": {
                      "sensitive": false,
                      "type": "string",
                      "value": "web-elb-1019323532.us-east-1.elb.amazonaws.com"
                  }
              },
              "resources": {},
              "depends_on": []
          },
          {
              "path": [
                  "root",
                  "elb"
              ],
              "outputs": {
                  "dns_name": {
                      "sensitive": false,
                      "type": "string",
                      "value": "web-elb-1019323532.us-east-1.elb.amazonaws.com"
                  }
              },
              "depends_on": []
          },
          {
              "path": [
                  "root",
                  "sg"
              ],
              "outputs": {
                  "security_group_id": {
                      "sensitive": false,
                      "type": "string",
                      "value": "sg-5a677425"
                  }
              },
              "depends_on": []
          },
          {
              "path": [
                  "root",
                  "web"
              ],
              "outputs": {
                  "web_instance_ids": {
                      "sensitive": false,
                      "type": "string",
                      "value": "i-03676fa6ba43fbb9f,i-09f51a313146856cd"
                  },
                  "web_public_ips": {
                      "sensitive": false,
                      "type": "string",
                      "value": "34.207.194.186,34.203.236.205"
                  }
              },
              "depends_on": []
          }
      ]
  }
  </code></pre>
  
  <p>I would like to get back a single json object where the output names are the keys and the values are the output values. Like in this example...</p>
  
  <pre><code>{
    "elb_dns_name": "web-elb-1019323532.us-east-1.elb.amazonaws.com",
    "dns_name": "web-elb-1019323532.us-east-1.elb.amazonaws.com",
    "security_group_id": "sg-5a677425",
    "web_instance_ids": "i-03676fa6ba43fbb9f,i-09f51a313146856cd",
    "web_public_ips": "34.207.194.186,34.203.236.205"
  }
  </code></pre>
  
  <p>I have only be able to get back single objects using this <code>.modules[] | .outputs | to_entries | map({(.key) : .value.value }) | add</code></p>
  
  <pre><code>{
    "elb_dns_name": "web-elb-1019323532.us-east-1.elb.amazonaws.com"
  }
  {
    "dns_name": "web-elb-1019323532.us-east-1.elb.amazonaws.com"
  }
  {
    "security_group_id": "sg-5a677425"
  }
  {
    "web_instance_ids": "i-03676fa6ba43fbb9f,i-09f51a313146856cd",
    "web_public_ips": "34.207.194.186,34.203.236.205"
  }
  </code></pre>
  
  <p>So for some reason I can't post, because stackoverflow says I have too much code and not enough details... so now I'm doing a diary entry in order to type enough that I can hit the submit button... any minute... any ammount of characters now... </p>
  
  <p>Okay so when I'm not building Code Pipelines at work I really like to play dota2. Only I think I'm pretty crappy at it. I mean I got 1200 hours in the gam and I'm still like 1.5k MMR trash. </p>