Amazon API Gateway with an Amazon S3 integration

Amazon API Gateway REST API → Amazon S3

Create a REST API Gateway with a S3 read-only integration

This pattern deploys an Amazon API Gateway REST API endpoint with a S3 read-only integration
The API exposes 3 GET methods:
Root GET method: it provides a list of the S3 buckets of the account where the stack is deployed.
{folder} GET method: it provides a list of the objects contained in the bucket {folder}
{item} GET method: it returns the contents of the object in Folders and Sub-folders {item+}
The template also deploys an IAM role with S3 read-only capabilities that is used by API Gateway to integrate with S3.
Since this is API Gateway effectively acts as a proxy S3, every GET method is protected by IAM authentication to prevent public access.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-s3-proxy

Deploy

Deploy the stack: <code>sam deploy</code>.


Testing

Once the application is deployed, retrieve the API URL provided as output and open it in a browser page.
Replace the folder and item place holder with S3 bucket name and path to your file
Example: https://12345abcde.execute-api.{region}.amazonaws.com/Prod/mybucket/folder1/folder2/index.html

Cleanup

Delete the stack: sam delete.

Additional resources

Created by:

Vamsi Pulikonda

Vamsi Pulikonda

I am a cloud computing enthusiast working as a Cloud Engineer at Amazon Web Services.

Follow on LinkedIn