Skip to content

How to get values from pseudo-nested maps? #20

Description

@emcniece

Hey, thank you for your work! Still doing some testing, but I've got a quick question: is it possible to get nested values from fake nested maps?

Context: I'm kind of hacking 0.11.0 to have nested maps, unable to upgrade to 0.12.0. I've got some environments that I want to iterate through elsewhere, and I'm trying to figure out how to get & set values inside a structure that looks like this:

locals {
  "block1" = {
    dev.env1  = "dev-var1"
    dev.env2  = "dev-var2"
    prod.env1 = "prod-var1"
    prod.env2 = "prod-var2"
    cat       = "meow"
  }
  "block2" = {
    dev.env3  = "dev-var3"
    dev.env4  = "dev-var4"
    prod.env3 = "prod-var3"
    prod.env4 = "prod-var4"
  }
}

So far, the only value I can extract from here is this:

cat test.tf | hclq get 'locals.block1.cat'
"meow"

Attempting to access the other commands seems to all return []:

cat ./test.tf | hclq get 'locals.block1.dev'
cat ./test.tf | hclq get 'locals.block1.dev.*'
cat ./test.tf | hclq get 'locals.block1.dev[]'
cat ./test.tf | hclq get 'locals.block1.dev[].*'
cat ./test.tf | hclq get 'locals.block1.dev.env1'
cat ./test.tf | hclq get 'locals.block1.dev.env1*'
cat ./test.tf | hclq get 'locals.block1.dev.env1.*'
cat ./test.tf | hclq get 'locals.block1.dev.env1[]'

Do you by chance know if it's possible to get & set the value for one of these dot-notated dev.env1 values?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions