简体   繁体   English

Jq 在使用 AWS Secrets Manager 解析时添加额外的双引号

[英]Jq adding extra double quotation marks when parsing with AWS Secrets Manager

My secrets are stored in AWS Secrets Manager in the following format:我的密钥以以下格式存储在 AWS Secrets Manager 中:

KEY_1   "XXXX"
KEY_2   0

I am trying to retrieve the secrets in the following format:我正在尝试以以下格式检索秘密:

KEY_1="XXXX"
KEY_2=0

that means the same way they're stored in Secrets Manager with = symbol.这意味着它们使用=符号存储在 Secrets Manager 中的方式相同。 I am using jq to parse in the following manner:我正在使用jq以下列方式解析:

aws secretsmanager get-secret-value --secret-id <secret_name> --output text --query SecretString \
| jq  -r 'to_entries[] | [.key, "=", "\"", .value, "\"" ] | @tsv' \
| tr -d "\t"

This command is working fine but with a small problem.该命令运行良好,但有一个小问题。 This command is adding an extra double quotation mark ( "" ) in the value field.此命令在value字段中添加一个额外的双引号 ( "" )。 It is giving the following output:它给出了以下 output:

 KEY_1=""XXXX""
 KEY_2="0"

But I do not want these extra double quotation marks to be added.但我不希望添加这些额外的双引号。 I want the output should be in the same format as described above while retrieving above ie, without extra quotation marks.我希望 output 在检索上述内容时应采用与上述相同的格式,即没有额外的引号。

You are outputting as text, what is the need for jq?您正在输出为文本,jq 需要什么?

--output text --输出文本

If you want to output as json you can use如果你想 output 作为 json 你可以使用

--output json --输出json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM