특정 IP 주소에 대한 액세스 제한/허용
- 조건에 지정된 IP주소 범위가 아니라면 거부.
설정
- 예시 : 54.240.143.0/24 만 허용.
- 해석 :
Resource
자원의 모든 Action
에 대해 SourceIp
가 아니라면 Deny
- 즉 54.240.143.0 ~ 54.240.143.255 만 허용
{
"Version": "2012-10-17",
"Id": "S3PolicyId1",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Deny", //거부
"Principal": "*",
"Action": "s3:*", //버킷에 대한 모든 액션에 적용
"Resource": [ //정책 적용 대상 자원
"arn:aws:s3:::awsexamplebucket1",
"arn:aws:s3:::awsexamplebucket1/*"
],
"Condition": {
"NotIpAddress": {"aws:SourceIp": "54.240.143.0/24"} //이 ip가 아니라면
}
}
]
}
예시 2
{
"Id":"PolicyId2",
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AllowIPmix",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:*",
"Resource":"arn:aws:s3:::awsexamplebucket1/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"54.240.143.0/24",
"2001:DB8:1234:5678::/64"
]
},
"NotIpAddress": {
"aws:SourceIp": [
"54.240.143.128/30",
"2001:DB8:1234:5678:ABCD::/80"
]
}
}
}
]
}