Vault: Support for multiline values

Created on 27 Sep 2016  路  1Comment  路  Source: hashicorp/vault

How can I write the contents of a multiline text file as value into vault?
As json file, which vault supports as file input, the newline characters still cause parse errors:

Error loading data: Invalid key/value pair '@/test.txt': invalid character '\n' in string literal

Also, for a json file, I have to prepend '{value:"' and append '"}' to
the file contents, including escaping quotes, which can be quite cumbersome.

Most helpful comment

Hi,

You can do it with a file, or with stdin:

$ vault write secret/foo zip=-
This
Is
Multiline<Ctrl-D><Ctrl-D>Success! Data written to: secret/foo

$ vault read secret/foo
Key                     Value
---                     -----
refresh_interval        720h0m0s
zip                     This
Is
Multiline

$ vault read -format=json secret/foo
{
        "request_id": "69647548-4215-6e20-949d-34dd515ccb97",
        "lease_id": "",
        "lease_duration": 2592000,
        "renewable": false,
        "data": {
                "zip": "This\nIs\nMultiline"
        },
        "warnings": null
}

>All comments

Hi,

You can do it with a file, or with stdin:

$ vault write secret/foo zip=-
This
Is
Multiline<Ctrl-D><Ctrl-D>Success! Data written to: secret/foo

$ vault read secret/foo
Key                     Value
---                     -----
refresh_interval        720h0m0s
zip                     This
Is
Multiline

$ vault read -format=json secret/foo
{
        "request_id": "69647548-4215-6e20-949d-34dd515ccb97",
        "lease_id": "",
        "lease_duration": 2592000,
        "renewable": false,
        "data": {
                "zip": "This\nIs\nMultiline"
        },
        "warnings": null
}
Was this page helpful?
0 / 5 - 0 ratings