Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akskap/3ccdae007c2c4c9de063c422aa61d96f to your computer and use it in GitHub Desktop.
Save akskap/3ccdae007c2c4c9de063c422aa61d96f to your computer and use it in GitHub Desktop.
IAM Policy Cross Account S3 Bucket Access
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "list-s3-resources",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<requester_acccount_id>:role/access-s3-objects"
},
"Resource": "arn:aws:s3:::my-test-bucket",
"Action": [
"s3:ListBucket",
"s3:ListBucketVersions"
],
"Condition": {
"DateGreaterThan": {
"aws:CurrentTime": "2020-04-01T00:00:00Z"
},
"DateLessThan": {
"aws:CurrentTime": "2020-05-30T23:59:59Z"
},
"StringLike": {
"s3:prefix": [
"test/sample-folder/",
"test/",
"test"
]
},
"IpAddress": {
"aws:SourceIp": "13.126.87.165/32"
},
}
},
{
"Sid": "get-s3-resources",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<requester_acccount_id>:role/access-s3-objects"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-test-bucket/*",
"Condition": {
"DateGreaterThan": {
"aws:CurrentTime": "2020-04-01T00:00:00Z"
},
"DateLessThan": {
"aws:CurrentTime": "2020-05-30T23:59:59Z"
},
"IpAddress": {
"aws:SourceIp": "13.126.87.165/32"
},
"StringEquals": {
"s3:ExistingObjectTag/available": "yes"
},
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment