3
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

Organization

S3でWebSite Hostingした時にIPアドレスで制限をかける

S3にstaticなHTMLをおいて、それを特定のIPからのみ見えるようにする方法。

いつも迷ってしまうので備忘録で書いておく。

Access Control List は変更する必要なし。( List objects の everyone も - のまま)
バケットの中のファイルもPrivateな設定のままでOK。

{
    "Version": "2012-10-17",
    "Id": "Policy1551163444222",
    "Statement": [
        {
            "Sid": "Stmt1551163442413",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::[Bucket Name]/*",
            "Condition": {
                "NotIpAddress": {
                    "aws:SourceIp": "[IP]"
                }
            }
        },
        {
            "Sid": "Stmt1551164678580",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::[Bucket Name]/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": "[IP]"
                }
            }
        }
    ]
}

いつも思ったように動かなくてもがくのは Resource 部分の最後に /* をつけ忘れて、ファイル見れないじゃん…ってなる。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
3
Help us understand the problem. What are the problem?