'Providing access to particular folder inside S3 bucket

I have a use where I need to provide temporary read access to particular folder in s3 bucket to some external users/services calling my service APIs where S3Uri of files in a particular folder will be returned in API response. There may be many folders inside bucket . Each service can read files in a particular folder.

Example : Bucket contains 2 folders :

A , B

External Service X calls my service API . X can only have access to read files in folder A . So if api response contains s3uri of any file in folder A then X can read it else permission denied for any file in folder B

How can I do that ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source