Skip to content

Instantly share code, notes, and snippets.

@shoemoney
Forked from ktrysmt/s3-bucket-policy.json
Created March 30, 2021 14:58
Show Gist options
  • Save shoemoney/86bf14381cc8803df9dcf31d023a395b to your computer and use it in GitHub Desktop.
Save shoemoney/86bf14381cc8803df9dcf31d023a395b 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