I have multiple s3 buckets and I want to maintain a common bucket policy across all my bucket. My bucket policy contains the bucket name as part of resource name and hence I am not able to maintain a single policy file for all my bucket. Is there any way to fetch the bucket name in the policy using any variable?
{
"Version": "2012-10-17",
"Id": "Policy1610615475618",
"Statement": [
{
"Sid": "Stmt1610615465140",
"Effect": "Deny",
"Principal": {
"AWS": "arn:aws:iam::<acc_name>:user/<user_name>"
},
"Action": "s3:PutObject",
"NotResource": [
"arn:aws:s3:::<bucket-name>/*.PNG",
"arn:aws:s3:::<bucket-name>/*.JPG",
"arn:aws:s3:::<bucket-name>/*.txt",
"arn:aws:s3:::<bucket-name>/*.mp3",
"arn:aws:s3:::<bucket-name>/*.Docx"
]
}
]
}