Skip to content

Instantly share code, notes, and snippets.

@ktrysmt
Created June 19, 2017 02:10
Show Gist options
  • Save ktrysmt/155a754c258899b08973116e0978a28f to your computer and use it in GitHub Desktop.
Save ktrysmt/155a754c258899b08973116e0978a28f to your computer and use it in GitHub Desktop.
a valid aws bucket policy json format for S3 to handle access controll by IP addresses.
{
"Version": "2008-10-17",
"Id": "Policy<UNIQUE ID>",
"Statement": [
{
"Sid": "Stmt<UNIQUE ID>",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::<UNIQUE ID>/*",
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"<IP ADDRESS>",
"..."
]
}
}
},
{
"Sid": "Stmt<UNIQUE ID>",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<BUCKET NAME>/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"<IP ADDRESS>",
"..."
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment