简体   繁体   English

将S3存储桶网站仅限于某些AWS账户

[英]Restrict S3 bucket website to certain AWS accounts only

I am looking to host a private website(html,js,css) in an S3 bucket and i want this website to be accessible only by aws accounts specified by me. 我希望在S3存储桶中托管一个私有网站(html,js,css),并且我希望该网站只能由我指定的aws帐户访问。

I read the question here - Restrict access to website hosted on S3 . 我在这里阅读了问题- 限制访问S3上托管的网站

The accepted answer says i can restrict access to a particular aws account. 接受的答案说我可以限制对特定aws帐户的访问。 But another answer says i cannot restrict by account. 但是另一个答案说我不能受帐户限制。

the main objective here is to give the url from the static website provided by amazon to give access to certain aws accounts. 这里的主要目的是提供由Amazon提供的静态网站的url,以访问某些AWS帐户。 Only authenticated aws accounts can access the site. 只有经过身份验证的AWS帐户才能访问该网站。

What i found on research shows that an S3 with website hosting enabled cannot have such restrictions and needs to be public. 我在研究中发现,启用了网站托管的S3不能有这种限制,需要公开。 Just wanted to know if there any workarounds. 只是想知道是否有任何解决方法。

I did look into serving with cloudfront signed urls but i cannot seem to authorise only certain aws accounts access. 我确实考虑过使用Cloudfront签名的URL进行服务,但似乎无法仅授权某些AWS帐户访问权限。 But this could be because i havent understood the concept completely. 但这可能是因为我还没有完全理解这个概念。 Or perhaps aws Cognito. 也许是Aogni Cognito。

Making a private website hosting is clearly documented here, 此处明确记录了进行私人网站托管的情况,

https://medium.com/@pvinchon/private-static-website-hosting-on-aws-s3-54664725b9e7 https://medium.com/@pvinchon/private-static-website-hosting-on-aws-s3-54664725b9e7

Once you have the website, enable the policy as below, 建立网站后,启用以下政策,

{
   "Version": "2012-10-17",
   "Statement": [
      {
         "Sid": "Example permissions",
         "Effect": "Allow",
         "Principal": {
            "AWS": "arn:aws:iam::AccountB-ID:root"
         },
         "Action": [
            "s3:GetBucketLocation",
            "s3:ListBucket"
         ],
         "Resource": [
            "arn:aws:s3:::examplebucket"
         ]
      }
   ]
}

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM