Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I debug my local vars? #2378

Closed
dr-egidijus opened this issue Dec 2, 2022 · 2 comments
Closed

How do I debug my local vars? #2378

dr-egidijus opened this issue Dec 2, 2022 · 2 comments
Labels
awaiting response Waiting for a response or more data from issue reporter question

Comments

@dr-egidijus
Copy link

Hello,
I have some local vars in my terragrunt.hcl
How can I print/evaluate show them ?
Can I see the structure without applying?

The source of my problem is that I am using map, merge, to merge a bunch of aws tags, and the module wants a string, not a map.

But I cannot see what exactly is being passed to the module, I have to rely on my understanding of terraform documentation.

@denis256
Copy link
Member

denis256 commented Dec 7, 2022

Hello,
may be helpful to use render-json command and get data in JSON format

terragrunt render-json
terragrunt render-json --with-metadata

References:
https://terragrunt.gruntwork.io/docs/reference/cli-options/#render-json

@denis256 denis256 added question awaiting response Waiting for a response or more data from issue reporter labels Dec 7, 2022
@dr-egidijus
Copy link
Author

dr-egidijus commented Dec 8, 2022

Thank you @denis256 that is very useful!

I had to create a "debug_vars" module like below.. but it was not as good.

main.tf

resource "null_resource" "terraform-debug" {
  provisioner "local-exec" {
    command = "echo $VARIABLE >> debug.txt"

    environment = {
        VARIABLE = jsonencode(var.debug_vars)
    }
  }
}

variables.tf

variable "debug_vars" {
  description = "accepts any type, any value passed as debug_vars for debugging."
  default     = null
}

then in terragrunt.hcl

terraform {
  source = "${get_path_to_repo_root()}//modules//debug_vars"
}

## all your code like locals etc here


inputs = {
  user_pool_name = "${local.user_pool_name}"
  tags = "${local.tags}"
  debug_vars = "${local.tags}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Waiting for a response or more data from issue reporter question
Projects
None yet
Development

No branches or pull requests

2 participants