【AWS CLI】aws s3api get-bucket-policyでS3のバケットポリシーを確認する
基本的な使い方 --bucketにバケット名を指定する。
$ aws s3api get-bucket-policy --bucket <bucket-name> 実行例
$ aws s3api get-bucket-policy --bucket example-bucket { "Policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"cloudfront.amazonaws.com\"},\"Action\":\"s3:GetObject\",\"Resource\":\"arn:aws:s3:::example-bucket/*\",\"Condition\":{\"StringEquals\":{\"aws:SourceArn\":\"arn:aws:cloudfront::123456789012:distribution/E1EXAMPLE123ABC\"}}}]}" } Policyの値はJSONオブジェクトではなく、エスケープされた文字列である。
そのままでは読みづらいため、次のように整形する。