在 bash 脚本中将变量传递给 aws cli 命令
我是编写Bash脚本的新手,并且在将变量传递到AWS CLI命令方面遇到了麻烦。我敢肯定,这很容易解决,而且我只是很难理解这种语法。以下是我到目前为止的脚本:
#!/bin/bash
CONFIG_RECORDER=`aws configservice describe-configuration-recorders
export CONFIG_RECORDER_NAME=$(jq -r '.ConfigurationRecorders[].name' <<<"$CONFIG_RECORDER")
sudo yum -y install jq
aws configservice delete-configuration-recorder --configuration-recorder-name $CONFIG_RECORDER_NAME
此脚本的目的是使用AWS CLI命令删除配置记录仪。我遇到了一个错误,aws:错误:参数 - configuration-recorder-name:预期一个参数
我有一个变量,$ config_recorder_name
,被指定为参数但是由于某种原因,它没有阅读。有关如何将此变量传递给此命令的任何建议将有所帮助。
I'm new to writing bash scripts and am having trouble with passing in variable to an AWS CLI command. I'm sure there's an easy fix for this, and I'm just having trouble understanding this syntax. Below is the script I have so far:
#!/bin/bash
CONFIG_RECORDER=`aws configservice describe-configuration-recorders
export CONFIG_RECORDER_NAME=$(jq -r '.ConfigurationRecorders[].name' <<<"$CONFIG_RECORDER")
sudo yum -y install jq
aws configservice delete-configuration-recorder --configuration-recorder-name $CONFIG_RECORDER_NAME
The purpose of this script is to delete the configuration recorder using the aws cli command. I'm getting an error that aws: error: argument --configuration-recorder-name: expected one argument
I have a variable, $CONFIG_RECORDER_NAME
, being specified as the argument but for some reason it is not reading. Any advice on how to pass in this variable to this command would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
aws configservice describe-configuration-recorders
调用返回单个配置记录器名称,以下内容似乎可以正常工作:实际上不需要使用
jq
。您可以简单地使用:The following seems to work correctly if the
aws configservice describe-configuration-recorders
invocation returns a single configuration recorder name:There's actually no need to use
jq
. You could simply use: