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

logged assignment function would be really valuable. #17265

Open
ghost opened this issue Feb 1, 2018 · 1 comment
Open

logged assignment function would be really valuable. #17265

ghost opened this issue Feb 1, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 1, 2018

Whenever I'm debugging something in terraform, it can be really difficult to figure out what is going wrong, depending on the nature of the error message that is being provided to the user (as opposed to the messages that often get swallowed by terraform which would actually allow me to know what is going on). Enabling debug or trace logging makes things so verbose it really isn't helpful in most instances.

What would be super helpful is the ability to easily inspect the contents of variables when resources are first created/updated. It seems like a function which does nothing but info-log the variable that is passed to it, before returning it, would be a really useful way to log the value of a variable when it gets used. This would be great for inspecting the values of 'computed' vars, unless terraform is passing a placeholder around during assignment and then populating the placeholder later or something similar. Will look into it and try to provide a PR, but if anyone has suggestions for where or how to implement this, I'd be happy to hear about it.

Something like this:

config {
  my_var = "${logvar(module.my_module.some_output_value)}"
}
@apparentlymart
Copy link
Member

Hi @sgendler-stem! Thanks for this feature request.

I like this idea! Unfortunately to implement it right now would just require it to be re-implemented shortly because we're about to change how the interpolation language deals with functions as part of integrating an improved language interpreter, but once we get past that and the relevant interfaces are stable again we have have a look into this and see what is the best way to implement it.

Perhaps this should have another argument to add some additional context to the log message. I think this would be useful because Terraform's parallelism means that the log lines would not necessarily appear in a predictable order:

    anything = log("module output", module.my_module.some_output_value)
[INFO] in aws_instance.foo, module output = abc123

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

No branches or pull requests

2 participants