0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[S3] 「バケットを空にする」に必要なポリシー

Last updated at Posted at 2022-08-02

IAMポリシーでs3:DeleteObjectを付与して、「バケットを空にする」を実行すると、結果のエラー列で、各オブジェクトでAccess Deniedが表示される。
結論、s3:getBucketVersioningも付与する必要がある。

※また、バケットの一覧 バケット内オブジェクトの一覧のリスト権限は必要ではないが、あった方が便利なので付与しておく
s3:ListAllMyBuckets s3:ListBucket

結果的に以下のようなポリシーのJSONとなる

※ListBucket/getBucketVersioningのResource限定してもいいかも

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:DeleteObject",
            "Resource": [
                "arn:aws:s3:::bucket1/*",
                "arn:aws:s3:::bucket2/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListAllMyBuckets",
                "s3:ListBucket"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "s3:getBucketVersioning",
            "Resource": "*"
        }
    ]
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?