I'm having difficulty creating an AWS S3 policy to allow a customer to list and access only certain objects with extensions in specific folders and subfolders, while not being able to list or access other folders, subfolders, or objects.
Let's say we have this structure:
S3
.
├── BucketManagement
| └── Accounting
|
├── BucketHR
| ├── Insurance
| └── Resume
|
└── BucketCustomers
├── custAcmeAnvils
├── custBoboBakery
| ├── projCakewalk
| | ├── batter.txt
| | ├── cupcake.txt
| | ├── PROFIT.XLS
| | └── cooktime.txt
| ├── projPieFace
| └── projFlourPower
| ├── dough.txt
| └── LAWSUITS.DOC
└── custCocoCabana
I've created an IAM user for my customer "Bobo's Bakery". I want to allow my customer Mr. Bobo to see and access only certain folders, subfolders, and objects (files). I don't want Mr. Bobo to see or access any other buckets, folders, subfolders, or objects.
In this example, I only want Mr. Bobo to be able to list and download the objects with the ".txt" extension in certain subfolders and not see, list, or access any other folders, subfolders, or objects with other extensions.
Ideally, when Mr. Bobo logs in to the S3 console, he sees ONLY this bucket (I know this may not be possible, as all buckets will have to be visible):
BucketCustomers
Then when Mr. Bobo clicks that bucket, he sees ONLY this folder "custBoboBakery":
BucketCustomers
└── custBoboBakery
Then when Mr. Bobo clicks that folder, he sees ONLY these 2 subfolders "projCakeWalk" and "projFlourPower":
custoBoboBakery
├── projCakeWalk
└── projFlourPower
Note: I do not want Mr. Bobo to see the subfolder projPieFace. Then when Mr. Bobo clicks either subfolder projCakewalk or projFlourPower, he sees ONLY objects with the ".txt" extension.
projCakewalk
├── batter.txt
├── cupcake.txt
└── cooktime.txt
projFlourPower
└── dough.txt
Mr. Bobo should not be able to see the objects with ".XLS" or ".DOC" extensions. He can then download those .txt files. Mr. Bobo should not have delete or upload permissions.
Can you advise how to write this policy?