Last active
December 29, 2020 06:38
-
-
Save dhavaln/9acebc460d1fd9b558f2ca47795ecb71 to your computer and use it in GitHub Desktop.
S3 Access Auth Role
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
- PolicyName: !Join ["-", [ "CognitoIDP", { Ref: AWS::StackName }, "S3-Access", "Policy"]] | |
PolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- Sid: "AllowListingPublicFiles" | |
Effect: Allow | |
Action: "s3:ListBucket" | |
Condition: | |
StringLike: | |
"s3:prefix": | |
- "public-files/*" | |
Resource: !Join ["", [ "arn:aws:s3:::", { Ref: s3FileBucket }]] | |
- Sid: "AllowListingUserFiles" | |
Effect: Allow | |
Action: "s3:ListBucket" | |
Condition: | |
StringLike: | |
"s3:prefix": | |
- !Join ["", [ 'users/', '${cognito-identity.amazonaws.com:sub', '}/*']] | |
Resource: | |
- !Join ["", [ "arn:aws:s3:::", { Ref: s3FileBucket }]] | |
- Sid: "AllowReadAccessPublicFolder" | |
Effect: Allow | |
Action: | |
- "s3:GetObject" | |
Resource: | |
- !Join ["", [ "arn:aws:s3:::", { Ref: s3FileBucket }, '/public-files']] | |
- !Join ["", [ "arn:aws:s3:::", { Ref: s3FileBucket }, '/public-files/*']] | |
- Sid: "ReadWriteDeleteOwnFiles" | |
Effect: Allow | |
Action: | |
- "s3:GetObject" | |
- "s3:PutObject" | |
- "s3:DeleteObject" | |
Resource: | |
- !Join ["", [ "arn:aws:s3:::", { Ref: s3FileBucket }, '/users/', '${cognito-identity.amazonaws.com:sub', '}']] | |
- !Join ["", [ "arn:aws:s3:::", { Ref: s3FileBucket }, '/users/', '${cognito-identity.amazonaws.com:sub', '}/*']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment