我是S3和云端的新手。
我在S3存储桶中有一个webapp。我从另一个应用程序重新路由到该应用程序。该重新路由包含查询字符串中的一些敏感信息,因此我只想接受https请求。 为此,我需要cloudfront并希望避免直接存取桶访问。
Bucket:abc.xyz.com.s3.amazonaws.com
网址:abc.xyz.com
我在cloudfront中启用了选项https only
和Restrict Bucket Access
。
虽然这在云端工作正常,但原始网址abc.xyz.com
似乎并未通过云端网络。 http
仍然可用且https
无效。
有没有办法只通过cloudfront强制访问存储桶?
铲斗政策:
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ORIGINACCESSID"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::abc.xyz.com/*"
}
]
}
答案 0 :(得分:0)
除了在CloudFront中将限制存储桶访问设置为是之外,您还需要将S3存储桶策略本身编辑为:
(将XXXXXXXXXXXXXX字符串替换为在CloudFront Distribution的Origin中为您创建的Origin Access ID)
{
"Version": "2012-10-17",
"Id": "Policy1476619022974",
"Statement": [
{
"Sid": "Stmt1415003054675",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity XXXXXXXXXXXXXX"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
}
]
}
您可以阅读有关使用原始访问标识限制访问Amazon S3内容here的更多信息。