Created
December 20, 2020 13:36
-
-
Save alex-samborskiy/be1332e9e411d4bc946175bf8bbdec43 to your computer and use it in GitHub Desktop.
[Private sub-folder os S3 bucket] #aws #s3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Sid": "AllowAccessToAllExceptPrivate", | |
| "Action": [ | |
| "s3:GetObject", | |
| "s3:GetObjectVersion" | |
| ], | |
| "Effect": "Allow", | |
| "NotResource": [ | |
| "arn:aws:s3:::bucket/prefix1/prefix2/private/*", | |
| "arn:aws:s3:::bucket/prefix1/prefix2/private" | |
| ], | |
| "Principal": { | |
| "AWS": [ | |
| "*" | |
| ] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://stackoverflow.com/questions/20432865/s3-bucket-policy-in-a-public-bucket-make-a-sub-folder-private | |
| After much digging through AWS documentation, as well as many trial and error permutations in the policy editor, I think I have found an adequate solution. | |
| Apparently, AWS provides an option called NotResource (not found in the Policy Generator currently). | |
| The NotResource element lets you grant or deny access to all but a few | |
| of your resources, by allowing you to specify only those resources to | |
| which your policy should not be applied. | |
| With this, I do not even need to play around with conditions. This means that the following statement will work in a bucket policy: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment