-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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 JSON output where it makes sense #2460
Comments
Almost sounds like you're going to use TF as an API 😉 |
@svanharmelen Cool! That's basically what I'm looking for. Would you mind maintaining that as a branch here in upstream instead? It would be much easier to rebase changes from upstream |
@radeksimko sure thing! If @mitchellh and @phinze are fine with that, I would certainly prefer that over having this kind of weird fork... So @mitchellh and @phinze what are your votes on this suggestion? |
The easiest way to implement this would be as a new UI hook that can be toggled with the |
What's the status of the terraform-api project? |
I was talking to @svanharmelen recently at dotGo and he was mentioning a conversation w/ @mitchellh where he wasn't quite inclined to add "API functionality" into Terraform since it significantly widens the impact/focus of Terraform (correct me if I'm wrong in the interpretation either of you). I was thinking about this for a while after dotGo and I must say I'm also inclined (I wasn't originally) to not have API included in TF core. It would probably simplify some of the projects I'm building on top of TF, but TBH all I care about is the output and I still believe we can do that without exposing everything over an API and bringing more complexity into Terraform's core. Hence I'm keeping this issue open, because I believe it would be still useful to have a machine-readable output. Many CLI tools in this area have a machine-readable output (e.g. kubectl, AWS CLI) and most of them don't need an API to accomplish that.
@svanharmelen will be best to answer that question. I think it's now maintained in the linked project. We were also discussing how to maintain that project without having to rewrite all the imports which truly makes maintenance bothersome. I think it would make sense to treat https://github.com/xanzy/terraform-api as a separate project that will be importing |
The current status of the Next to that I think I have a solution for the current approach which clearly isn't ideal (certainly with regards to the import rewriting stuff). When looking at the amount of code I added to make TF behave like an API, you can see it's actually very little code and mainly contained into the api package. So I'm currently thinking about having a microservice that supports both an HTTP+JSON and gRPC endpoint that only imports Terraforms' packages. This way there is no need to fork the whole project and rewrite all imports. So that would make it a very lean and mean API wrapper around Terraform IMO. |
#6299 seems to be addressing a few points from the list ( |
+1 |
1 similar comment
+1 |
+1 |
The comments on #10665 probably apply to much of what's described here. |
+1 |
Is still this worked on ? |
Hi all! Thanks for the great discussion here. Over time experience has shown us that this sort of "meta-issue" is not that useful, since it represents work that can potentially span across a long period of time. Machine-readable output from Terraform is definitely a goal, but we are being cautious about it while the product is still pre-1.0 and so details about it are changing a lot between releases. Supporting JSON output would create compatibility constraints that are likely to hurt our ability to improve the core functionality of Terraform. So for now I'm going to close this, to make it explicit that machine-readable output is not on the docket at the moment. When things are getting more stable, we'll come back to this by making a set of more-specific issues that each cover particular use-case, but it's too early to do that today. |
We have a case with our own representation of resources, which is the processed in various ways: configures environments in special ways and renders to terraform format. This way we are handling many deployments. |
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. |
As discussed previously elsewhere, it would be useful to have JSON output coming from certain terraform commands, especially when people use it as an abstraction layer in another project/tool instead of a standalone tool in CLI.
The assumption is we'd have
-format=json
argument accepted for the commands below.At some point all the commands could have JSON output, but I do aim to cover at least the basic use-cases first:
apply
apply
implying-input=false
&-no-color
apply
- list of errorsapply
- refresh events log (e.g.aws_vpc.main: Refreshing state... (ID: vpc-1a131c7f)
) -> I'd begin with (potentially long) string 1:1 buffered output of what we have alreadyapply
- execution events log (e.g.aws_vpc.main: Creation complete
) -> I'd begin with (potentially long) string 1:1 buffered output of what we have alreadyapply
- sums of modified resources (e.g.{"created": 1, "changed": 0, "removed": 0}
)apply
- list ofoutput
sdestroy
destroy
implying-force
&-no-color
destroy
- list of errorsdestroy
- refresh events log (e.g.aws_vpc.main: Refreshing state... (ID: vpc-1a131c7f)
) -> I'd begin with (potentially long) string 1:1 buffered output of what we have alreadydestroy
- execution events log (e.g.aws_vpc.main: Destruction complete
) -> I'd begin with (potentially long) string 1:1 buffered output of what we have alreadydestroy
- sums of modified resources (e.g.{"created": 0, "changed": 0, "removed": 3}
)plan
plan
implying-no-color
plan
- refresh events log (e.g.aws_vpc.main: Refreshing state... (ID: vpc-1a131c7f)
) -> I'd begin with (potentially long) string 1:1 buffered output of what we have alreadyplan
- readable version ofterraform plan -out
output
This will likely require #1209 / #2335 / #2390 to make the output actually useful.
output
implies-no-color
output
- list of outputsversion
Just because any 3rd party tool likes to know that and because it's IMO super easy to do this one.
version
returns{"version": "0.6.0-dev", "git_commit": "62baf79+CHANGES"}
The suggested approach for events log will likely increase memory usage, but it's the easiest solution I can think of now. I'd love to see something more sophisticated in the future though - e.g. Terraform exposing sockets API that streams out event by event.
The text was updated successfully, but these errors were encountered: