How to Recreate Terraform map with duplicate keys?

Viewed 124

I'm getting terraform Local variable output as below. I want to reconstruct it to use in deferent argument. I have tried it many way , Still no luck, Appreciate community support on this.

    snap_id_list = [
  {
    "3" = {
      "/x01" = "snap-01397a07b574e781f"
    }
  },
  {
    "2" = {
      "/x04" = "snap-035d6c4165d34041a"
    }
  },
  {
    "1" = {
      "/x04" = "snap-07bc61be86cb0b3a2"
    }
  },
  {
    "3" = {
      "/x04" = "snap-0aa3a4d1cbd87531b"
    }
  },
  {
    "1" = {
      "/x01" = "snap-0e501f7d2798eeb70"
    }
  },
  {
    "2" = {
      "/x01" = "snap-0fe2fe503e433fdbd"
    }
  },
]

I want to recreate it as below using common keys.

snap_id_list = [
  {
    "3" = {
      "/x01" = "snap-01397a07b574e781f"
     "/x04" = "snap-0aa3a4d1cbd87531b"
  },
  {
    "2" = {
      "/x04" = "snap-035d6c4165d34041a"
      "/x01" = "snap-0fe2fe503e433fdbd"
  },
  {
    "1" = {
      "/x04" = "snap-07bc61be86cb0b3a2"
      "/x01" = "snap-0e501f7d2798eeb70"
    }
  },
  
]
0 Answers
Related