AWS CLI - 一行和第二级JSON的单行上的输出文本
我正在尝试从AWS证书管理器中获得其域名,有效数据,验证状态和验证方法的证书列表(例如100),并使用AWS CLI命令 AWS ACM DICESS ACM DICECT-CREDICETIFICATE
。
我尝试了嵌套过滤和 - ouput Text
,但输出在两行上。我想原因是验证status和validationMethod在JSON OUPUT中是第二级,仅次于证书/域名。
如何将文本ouput插入一行?
例如
foo.bar.com 2022-06-18T23:59:59+00:00 FAILED DNS
这是 - 输出文本
$ aws acm describe-certificate --certificate-arn arn:aws:acm:region:aws-account_id:certificate/xxxx --query Certificate.[DomainName,NotAfter,DomainValidationOptions[].[ValidationStatus,ValidationMethod]] --output text
foo.bar.com 2022-06-18T23:59:59+00:00
FAILED DNS
这是 -
- 输出JSON
(默认输出)
aws acm describe-certificate --certificate-arn arn:aws:acm:region:aws-account_id:certificate/xxxx --query Certificate.[DomainName,NotAfter,DomainValidationOptions[].[ValidationStatus,ValidationMethod]]
[
"foo.bar.com",
2022-06-18T23:59:59+00:00,
[
[
"FAILED",
"DNS"
]
]
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实现此目标的一种方法是在Jmespath 平坦的操作员 -
[]
- 在您的查询中。有这样的查询:
将为您提供一个域,一个域,JSON输出
并最终进入一行。
现在,请注意,如果您在
domainvalidationOptions
数组中有多个项目,那么它们将在同一行上所有输出,因为您将拥有一个数组。两个域的示例:
请参阅DNS和
验证status
和verialationMethod
重复那里的两个域?您可能想做的是从域中查询
domainname
,至少至少:它仍然在一条线上,但会为您提供与验证相关的域:
A way to achieve this is to flatten the array you are receiving from the AWS command, with the help of the JMESPath flatten operator —
[]
— in your query.Having a query like this:
Would give you, with one domain the JSON output
And end up on one line.
Now mind that, if you have more than one item in the
DomainValidationOptions
array, they will, then, all output on the same line, because you'll have one array with everything.Example for two domains:
See the DNS and
ValidationStatus
andValidationMethod
repeating for the two domains there?What you might want to do, is to query the
DomainName
from the DomainValidationOptions, at least:Which would still be on one line, but will get you the domain related to the validation:
使用约翰的建议取得了一些进展。
通过使用“ Inuseby [0]”和“ Inuseby”,我设法在第一行中输出“ Inuseby”;否则将在第二行。
还使用“ domainvalidationOptions [0] .ValidationStatus”而不是“ domainvalidationOptions.ValidationStatus”将其输出在第二行而不是第3行上。
尽管如此,我还是希望
也要在第一行上输出。我注意到续订是一个对象,{},而不是数组,[]。
这就是输出的外观:
Some progress was made using John's suggestion.
By using "InUseBy[0]" and not only "InUseBy", I managed to output the "InUseBy" on the first line; otherwise it would be on the second line.
Also using "DomainValidationOptions[0].ValidationStatus" instead of "DomainValidationOptions.ValidationStatus" outputs this on the 2nd line instead of 3rd.
Still, I would like
to be output on the first line too. I noticed RenewalSummary is an object ,{}, not an array, [].
This is how the output looks now: