如何將變數傳遞到json檔案中

如何將變數傳遞到json檔案中

我正在嘗試將變數傳遞到 json 檔案。

這是我的腳本:

#!/bin/sh
for BucketName in `aws s3api list-buckets | jq '.Buckets[].Name' | sed 's/"//g'`;
do
if [ "$(aws s3api put-bucket-policy --bucket $BucketName --policy file://policy.json)" ]; then
echo "Passed"
elso
echo "Failed"
fi
done

file://policy.json需要傳遞一個BucketName在 for 迴圈中呼叫的變數。

這是我的 json 檔:

{
   "Sid":  ,
   "Effect": "Deny",
   "Principal": "*",
   "Action": "s3:GetObject",
   "Resource": "arn:aws:s3:::"'$BucketName'"/*",
   "Condition": {
       "Bool": {
           "aws:SecureTransport": "false"
       }
   }
}

任何想法?

相關內容