Articles → AWS → Folder-Wise Access In The AWS S3 Bucket

Folder-Wise Access In The AWS S3 Bucket






Scenario




Picture showing 2 folders inside the S3 bucket





Create A User




Picture showing the test user created in AWS console



Create A Policy




{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "sid1",
            "Action": [
                "s3:ListAllMyBuckets",
                "s3:ListBucket"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::*"
            ]
        },
        {
            "Sid": "sid2",
            "Action": [
                "s3:ListBucket"
            ],
            "Effect": "Deny",
            "Resource": [
                "arn:aws:s3:::*"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:prefix": [
                        "folder2/"
                    ]
                }
            }
        }
    ]
}





Output




Picture showing the user is able to access folder1


Picture showing the error message when user is trying to access folder2





Posted By  -  Karan Gupta
 
Posted On  -  Monday, June 6, 2022

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250