-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Vault CLI support for HCL input throughout by converting to JSON #3796
Comments
@jgiles The values stored in |
Vault's entire API is JSON. The K/V stores JSON; for ease of general use when using |
The secret example was perhaps ill-chosen; it was just the simplest example of "I want to put an object in Vault". I'm not actually trying to write secrets in HCL and store them. What I'm actually trying to do is write down auth and secret backend configuration (e.g. Okta config, Duo config, users, groups, SSH CA config, SSH roles, Postgres roles, MSSQL roles, etc) in the style of the Codifying Vault Policies and Configuration blog post. Since Vault's entire API is JSON, I can write all this configuration down as JSON files. That is what we do currently, but JSON is sub-optimal as a configuration language in many ways - I can't leave comments, and the syntax is verbose and unforgiving (don't forget that comma! no, you can't break that huge SQL statement string up into multiple lines!). HCL is a minimal extension of JSON and works better as a configuration language. Vault already seems to recognize the difficulties of using JSON as a configuration language: It supports specifying policies as HCL (in addition to JSON, since all JSON is valid HCL). The suggestion here is to stop treating policies as a special case: Keep the entire Vault API as JSON. Support humans writing Vault data in HCL by converting it to JSON on the client side before POSTing it to the server. Note that it might even make sense to do this for policies themselves (thus truly honoring "Vault's entire API is JSON"). The main thing you would lose would be the particular format of the input HCL file, but it's not clear that you really want to store and return functionally-equivalent policies as different strings. You could always store the raw HCL input on the side for a human-format response. On the other hand, a straight JSON version of the policy would be much more easily interoperable with tools that might grab policies from the API. |
@jefferai any thoughts on the above clarification of the feature request? |
The problem with this is that it requires some heuristics in the CLI that I would prefer we don't codify in for everybody, especially since there are tools out there that can convert HCL to JSON, at which point you can easily pipe the output of such a tool into the input of the CLI. I'm not disagreeing with the issues around JSON, at all, but I don't think the solution in the general case is to support HCL for any given input, especially given that there are few API calls that generally take more than a few parameters, and for policies HCL can be provided as-is since that's codified as the official input. |
Feature Request: Vault CLI support for HCL input throughout by converting to JSON
Environment:
Vault Config File:
Running
-dev
with default config.Startup Log Output:
Expected Behavior:
Similar to policy value
.hcl
files, I would like to encode other Vault config files using HCL and write them using the Vault CLI. This provides friendlier syntax (e.g. comments, no trailing-comma fragility).Actual Behavior:
Policy values are "special" with HCL handling on the server side. Other configs need to be written using JSON.
Steps to Reproduce:
References:
https://www.hashicorp.com/blog/codifying-vault-policies-and-configuration.html is the inspiration for our desired workflow.
#3795 discusses general difficulty with posting complex values to the API (including properly encoding policies).
I realize I can do the above conversion operation myself across the board, but it would be nice if the Vault client did HCL handling and communicated to the server using JSON. This would make policies less "special", simplify the broad use of HCL in codified Vault configs, and generally encourage API consistency of the sort discussed in #3795
The text was updated successfully, but these errors were encountered: