如何在S3中设置存储桶策略,允许静态网站托管,同时限制部分IP访问文件?
以下为静态托管的存储桶策略示例,供参考:
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::example-bucket/*"
]
}
]
}发布于 2015-02-14 18:51:42
添加用于拒绝某些IP地址或IP地址范围的condition。对于example,可以使用以下命令:
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::example-bucket/*"
],
"Condition": {
"NotIpAddress": {
"aws:SourceIp": ["200.1.11.123"]
}
}
}
]
}https://stackoverflow.com/questions/28501509
复制相似问题