Skip to content

Instantly share code, notes, and snippets.

@kdabir
Last active January 11, 2024 02:25
Show Gist options
  • Save kdabir/9c086970e0b1a53c3df491b20fcb0839 to your computer and use it in GitHub Desktop.
Save kdabir/9c086970e0b1a53c3df491b20fcb0839 to your computer and use it in GitHub Desktop.
json in heredoc in bash script alongwith variable substitution
_BUCKET_NAME="foo.example.com"
_POLICY=$(cat <<EOT
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::${_BUCKET_NAME}/*"]
}]
}
EOT
)
echo ${_POLICY}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment