【发布时间】:2021-01-15 20:25:46
【问题描述】:
我正在尝试使用 yq https://github.com/mikefarah/yq v4.3.2 在 CloudFormation 模板中添加 yaml 值,如下所示:
Mappings:
RegionMap:
us-east-1:
AMI: 'ami-YeahRight'
相反,我得到的是:
Mappings:
RegionMap:
us-east-1:
AMI: ami-YeahRight
文档中的样式位和来自这个 SO 答案 yq processing a string with quotation marks 让我认为 bash 脚本的这一部分可以工作,但是样式部分被忽略了。
region="us-east-1"
ami="ami-YeahRight"
echo Inserting $ami into $region
yq eval '.Mappings.RegionMap.'"$region"'.AMI='"$ami"' style="single"' -i temp.yaml
我已经尝试了一大堆类似的位,但似乎无法破解这个坚果。在这里的任何帮助将不胜感激!
【问题讨论】: