简体   繁体   中英

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 .

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>/*"
    }
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM