我希望存储在S3存储桶中的文件只对位于EC2实例上的特定web应用程序的用户可用。
这里有答案,但它会导致一个已删除的链接。。。
这里也有解释,但我不知道如何实现解决方案。。。我应该在某个地方包含这个代码:
{
"Version":"2012-10-17",
"Id":"http referer policy example",
"Statement":[
{
"Sid":"Allow get requests originated from www.example.com and example.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::examplebucket/*",
"Condition":{
"StringLike":{"aws:Referer":["http://www.example.com/*","http://example.com/*"]}
}
}
]
}
我该怎么做?
您的上述代码是aws安全策略。。。。。
你需要做以下事情:
Step1: Create a IAM user from AWS Dashboard -> Users -> Create New Users.
Step2: Create a policy for your bucket from AWS Dashboard -> Policies -> Get Started -> Create Policy.
Step3: Attach the policy created in Step2 to the user created in step1.
现在,只有使用指定策略创建的用户才能访问bucket。
由于您的保单有一条规则
"aws:Referer":["http://www.example.com/*","http://example.com/*"]
bucket将只能从您指定的url访问。