現象
S3にアップロードした画像のオブジェクトに移動し、オブジェクトURLにアクセスしても下記のように表示されてしまい、画像が表示されない。
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>FDNGTP38N87SEYB9</RequestId>
<HostId>IYV4WCW2cNiFmQIiJmHJbSgtdlJzq2cqz/UQ2E9RmEN6/1QFtBFOxvQMyhtl133IvyDLOkRQsM4=</HostId>
</Error>
WP Offload Mediaプラグインを使用して、WordPressから画像を投稿したら、S3に保存されるようにし、画像の配信もS3から行うようにしている。
このとき、画像を投稿すると、編集画面で「画像にalt属性が指定されていません。」と表示され、正常に画像が表示されない。
対処
下記のコードをコピーする
{
"Sid": "Read",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::{自分のバケット名}/*"
}
![FireShot Capture 091 - aws-and-infra-wp21301 - S3 バケット - S3 - ap-northeast-1_ - [ap-northeast-1.console.aws.amazon.com].png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F4237108%2F5eeaa963-9f4a-4e4a-a9fd-416652e46134.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=85f931249b4cd2201e597354732af92c)