
我正在嘗試將變數傳遞到 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"
}
}
}
任何想法?