Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve aws s3 bucket policy in json pretty format

Retrieving AWS S3 bucket policy in pretty json format.

aws \
--profile AWS_PROFILE  \
s3api get-bucket-policy \
--bucket AWS_S3_BUCKET \
--query Policy --output text | jq .
like image 976
Shivu RH Avatar asked Nov 22 '25 05:11

Shivu RH


1 Answers

You can try the following:

aws s3api get-bucket-policy \
    --bucket <AWS_S3_BUCKET> \
    --query Policy --output text --profile la | jq

Example output:

{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "AllowPublicRead",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::<bucket-name>/*"
    }
  ]
}

like image 152
Marcin Avatar answered Nov 24 '25 01:11

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!