1
1

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.

AWS関連の自分のブログ振り返りAdvent Calendar 2022

Day 7

S3 バケットポリシー設定時のエラーへの対処方法

Posted at

問題

S3のバケットポリシーで GetObject を定義した際、『Action does not apply to any resource(s) in statement』というエラーが表示されて失敗する。
【エラー画面】

【バケットポリシー 修正前】

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "PublicRead",
			"Effect": "Allow",
			"Principal": "*",
			"Action": [
				"s3:GetObject",
				"s3:GetObjectVersion"
			],
			"Resource": "arn:aws:s3:::【バケット名】"
		}
	]
}

解決方法

Resource部分のバケットの指定方法が間違っていました。
バケット配下のオブジェクトに対応するように部分修正をします
"Resource": "arn:aws:s3:::{mybucket}/*"

【バケットポリシー 修正後】

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "PublicRead",
			"Effect": "Allow",
			"Principal": "*",
			"Action": [
				"s3:GetObject",
				"s3:GetObjectVersion"
			],
			"Resource": "arn:aws:s3:::【バケット名】/*"
		}
	]
}

さいごに

根本的な問題は書き慣れていないことですが、こういったことを踏まえながら手を動かしていきたいと思います。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?