Inspect attributes

is there a way to inspect attributes prior to deploying? e.g. digitalocean_droplet.container.* all the ones that * would expand to? I’m aware of the provider documentation, but if I e.g. use for_each instead of count, the attributes change.

What do you mean by inspecting the attributes? Terraform’s plan will display the planned changes before applying them; is there something missing from its output that you expect to see?

I’d basically like to preview variable contents, something alike to console.log()'ing out what digitalocean_droplet.container contains.

I may be onto something with outputs - but do they e.g. output to a planning stage so I could inspect it and does it e.g. stringify arrays?

If you run the interactive command terraform console you can enter expressions like digitalocean_droplet.container at the prompt to see what they evaluate to when considered against the current state. You can use arbitrary expressions here, so you can also try the effect of function calls and other operators.

If it’s an object you’ve not created yet then the data about it is likely to be incomplete, as normally illustrated as (known after apply) in a plan. However, you can still inspect the subset of data that Terraform knows at that point. If you’re running terraform console before you ever ran terraform apply then that subset will be only the values specified directly in the configuration, and expressions which derive from those.

1 Like

That sounds very promising, however is there a way to play with module variables too? because if you run it on the regular project it just returns

A managed resource xxx has not been declared in the root module.

Figured out you have to define outputs to be able to access those in console via module.*