LoginSignup
0
0

More than 3 years have passed since last update.

An error occurred (AccessDenied) when calling the PutBucketPolicy operation: Access Denied

Last updated at Posted at 2021-04-22

はじめに

AWSのチュートリアル「Build a Modern Web Application <Module 1: Build a Static Website>」を進める際に躓いた点があったのでメモ。

発生したエラー

「Step3: Host The Website On S3」の「B: Update The S3 Bucket Policy」でウェブサイトにパブリックバケットポリシーを追加する際に以下のエラーが発生しました。

Bash
$ aws s3api put-bucket-policy --bucket REPLACE_ME_BUCKET_NAME --policy file://~/environment/aws-modern-application-workshop/module-1/aws-cli/website-bucket-policy.json
An error occurred (AccessDenied) when calling the PutBucketPolicy operation: Access Denied

「『PutBucketPolicy』を実行しようとしたけどアクセスできませんでした」とのことらしいです。

解決方法

こちらのサイトを参考にしました。

  1. Amazon S3コンソールにて、「Step3: Host The Website On S3」の「A: Create An S3 Bucket And Configure It For Website Hosting」で作成したバケットを選択します。

  2. 「アクセス許可」タブの「ブロックパブリックアクセス(バケット設定)」を編集します。

  3. 「パブリックアクセスをすべてブロック」のチェックを外し、変更を保存します。

おそらくこれで先ほどのCLIコマンドが実行できると思います。コマンドを実行してパブリックバケットポリシーを追加した後は、「パブリックアクセスをすべてブロック」を再びチェックしておいたほうがいいかもしれません。(理解不足)パブリックアクセスのブロックがどのような影響を及ぼすのか要調査。

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