我写了一个脚本在本地堆栈上创建sqs资源。我想将从一个cli命令获得的值传递给下一个命令,但要放在一个内嵌json中。以下是有问题的脚本部分。
arn=$(aws --endpoint-url=http://localhost:4576 sqs get-queue-attributes \
--queue-url http://localhost:4576/my_dead_letter_queue_url \
--query 'Attributes.QueueArn' \
--output text)
aws --endpoint-url=http://localhost:4576 sqs create-queue \
--queue-name my_queue \
--attributes \
'{"RedrivePolicy":"{\"deadLetterTargetarn\":\"$arn\",\"maxReceiveCount\":\"5\"}"}'
因此,我尝试传递“ arn”变量,但cli将其作为字符串并尝试找到URL为“ $ arn”的sqs并失败。我也尝试删除报价。在这种情况下,错误是字符串格式错误。
如果我使用arn值代替那里的arn变量,它将代替arn变量。
有人可以告诉我如何在行内json中传递该变量吗?
感谢您阅读:)
Shahed