3
4

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 5 years have passed since last update.

AWSのS3で静的サイトをホスティングしてみた。

Last updated at Posted at 2017-03-31

AWSのS3で静的サイトをホスティングしたので、気づいたことを自分用にメモしておく。

S3とは

Amazon S3 は、インターネット用のクラウドストレージ。
参考にしたURL
http://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/WebsiteHosting.html

手順

1.AWSのコンソールにサインインして、s3のバケットを作成する。
→ココから https://console.aws.amazon.com/s3/
参考:http://docs.aws.amazon.com/ja_jp/AmazonS3/latest/user-guide/create-bucket.html
・バケット名は独自ドメインと同じにする。
・リージョンは現在地に近い場所、例:Tokyo

2.静的webサイトとしてバケットを設定
a.バケットの [Properties] パネルで [Static Website Hosting] をクリック
b.[Enable website hosting] を選択
c.[Index Document] ボックスにindex.htmlを追加

3.アクセス権限の設定
a.バケットの [Properties] ペインの [Permissions] をクリック
b.[Add Bucket Policy] をクリック
c.下のバケットポリシーをコピーし、Bucket Policy Editor に貼り付け
※example-bucketは、自分のバケット名と置き換え。

{
  "Version":"2012-10-17",
  "Statement":[{
	"Sid":"PublicReadForGetBucketObjects",
        "Effect":"Allow",
	  "Principal": "*",
      "Action":["s3:GetObject"],
      "Resource":["arn:aws:s3:::example-bucket/*"
      ]
    }
  ]
}

4.index.htmlをアップロード
a.https://console.aws.amazon.com/s3/にアクセス、[Bucket name] リストで、オブジェクトのアップロード先のバケットの名前を選択
b.[Upload] を選択します。
c.ローカルにindex.htmlとテストファイルを作成し、uplload。
※バケットが空の場合、[Get started] または [Upload] を選択できる。
参考:http://docs.aws.amazon.com/ja_jp/AmazonS3/latest/user-guide/upload-objects.html

3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?