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

Allow printing and/or saving output vars #1209

Closed
radeksimko opened this issue Mar 16, 2015 · 9 comments
Closed

Allow printing and/or saving output vars #1209

radeksimko opened this issue Mar 16, 2015 · 9 comments

Comments

@radeksimko
Copy link
Member

It would be nice if terraform could be moving a bit towards the concept of "stacks" and sharing variables between these stacks. Inspiration here.

Module is a nice concept for code reuse, putting aside the fact that dependencies don't work well yet, it's generally not always the right solution for all problems anyway.

I'm not sure how the right API & wrapper should look like, but here's an idea:

.
├── networking-stack
│   ├── template.tf
│   ├── terraform.tfout
│   └── networking-input.tfvars
├── computing-stack
│   ├── template.tf
│   ├── terraform.tfout
│   ├── networking-input.tfvars (symlink to ../networking-stack/terraform.tfout)
│   └── computing-input.tfvars
...

Which already expects #1084 to be solved.

I believe it should have a special extension (tfout or any similar) so that if it gets generated into the same directory, it is not picked up in next run as an input.
I believe it should be generating this output by default to any default location (terraform.tfout ?) so that user doesn't have to think about passing extra option for each stack. More importantly the only way I can get to the output now is to open a (possibly giant) *.tfstate and look for outputs which isn't really nice experience.

This could also be helpful for #610

@radeksimko
Copy link
Member Author

I'm just looking at terraform output and thinking that it could be the right place for such functionality...

  1. We could make the argument NAME optional and if it's not provided, it will simply print all the variables in format key=value (obviously escaped strings if necessary).
  2. We could also add a new argument -out=path which would write the output to that file instead of stdout. Default may still be /dev/stdout.
Usage: terraform output [options] NAME

  Reads an output variable from a Terraform state file and prints
  the value.

Options:

  -state=path      Path to the state file to read. Defaults to
                   "terraform.tfstate".

@mitchellh
Copy link
Contributor

So, tfvars format is just JSON, so I think we can add a -format=json flag to terraform output to do this. I like it.

@ketzacoatl
Copy link
Contributor

+1

@radeksimko radeksimko changed the title Allow saving output vars in a tfvars format Allow printing and/or saving output vars Jun 14, 2015
@migibert
Copy link

+1

@donovanmuller
Copy link

+1

2 similar comments
@chiriaev
Copy link

+1

@grebois
Copy link

grebois commented Oct 13, 2016

+1

@mitchellh
Copy link
Contributor

Going to centralize on Radek's mega issue since this is fairly simple (#2460)

@ghost
Copy link

ghost commented Apr 20, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants