我试图限制对几个不同子网中的 EC2 实例的 S3 存储桶访问:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Principal": {"AWS": "*"},
"Resource": [
"arn:aws:s3:::test.bucket",
"arn:aws:s3:::test.bucket/*"
],
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"192.168.129.64/27",
"192.168.129.96/27",
"192.168.128.64/26"
]
}
}
},
{
"Effect": "Deny",
"Action": "s3:*",
"Principal": {"AWS": "*"},
"Resource": [
"arn:aws:s3:::test.bucket",
"arn:aws:s3:::test.bucket/*"
],
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"192.168.129.64/27",
"192.168.129.96/27",
"192.168.128.64/26"
]
}
}
}
]
}
我知道关于这项政策的特殊性还有其他问题,但除了条件之外,我已尝试使其尽可能简单。不幸的是,尝试aws s3 ls s3://test.bucket
从 IP 地址为 的 ec2 实例执行简单操作192.168.129.100
失败并拒绝访问。这项政策有效地将我拒之门外。
我不知道我错过了什么。我什至尝试在and条件之前添加ForAnyValue
和。ForAllValues
IpAddress
NotIpAddress