LoginSignup
0
0

More than 1 year has passed since last update.

"s3:DeleteObject*"をポリシーに組み込まない場合の挙動

Posted at

What's This

"s3:DeleteObject*"をポリシーに組み込まない場合、
S3バケットに同名のファイルをアップロードしたら、元のファイルが上書きされるか調査した時のメモです。

あくまでメモなので、参考にされる場合は、公式ドキュメント等の副読的な感じで読まれると幸いです。

やってみた

# ロールに適用したポリシー
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject*",
                "s3:ListBucket",
                "s3:GetObject*"
            ],
            "Resource": [
                "arn:aws:s3:::`S3 Bucket`",
                "arn:aws:s3:::`S3 Bucket`/*"
            ]
        }
    ]
}
# S3バケットに、同名のファイルをアップロードした場合、元のファイルが上書きされるか確認
$ aws s3 ls s3://`S3 Bucket`
2022-xx-xx xx:xx:xx     xxxxxx test-image.png

# 適当に同じ名前のファイルを作成
$ touch test-image.png

# アップロードしたとき、上書きされるか
$ aws s3 cp ./test-image.png s3://`S3 Bucket`
upload: ./test-image.png to s3://`S3 Bucket`/test-image.png

日時から、上書きされていることを確認。

スクリーンショット 2022-03-09 15.56.13.png

スクリーンショット 2022-03-09 15.56.23.png

念の為、上書き前後で中身も変わっているか確認

$ date | tee date.txt
2022年 3月 9日 水曜日 17時00分10秒 JST

$ cat date.txt
2022年 3月 9日 水曜日 17時00分10秒 JST

$ aws s3 cp ./date.txt s3://`S3 Bucket`
upload: ./date.txt to s3://`S3 Bucket`/date.txt

S3 GUIでダウンロードして中身を確認。

スクリーンショット 2022-03-09 17.06.23.png

$ date | tee date.txt
2022年 3月 9日 水曜日 17時07分32秒 JST

$ aws s3 cp ./date.txt s3://`S3 Bucket`
upload: ./date.txt to s3://`S3 Bucket`/date.txt

S3 GUIでダウンロードして中身を確認。

スクリーンショット 2022-03-09 17.08.23.png

中身も変わっていることを確認。

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