Host Your Swagger-UI of AWS Lambda Using Amazon S3

A step by step guide of hosting a static Swagger-UI in front of your AWS Lambda

Kevin Mun
Learn AWS

--

Problems

Initially, my team is working on hosting our serverless API in Lambda, along with our Swagger frontend. However, it will occasionally hit an error of loading failed due to extensive processes due to import Swagger files externally and consume our Swagger. YAML file. Besides that, Swagger is not a necessity to our API when it comes to production level. So we decided to move our Swagger away from our API to keep it short and straightforward.

S3 provides a simple way to host a static website without much configuration. It best suits our case here. So let’s get started.

Solution

1. Host your swagger configuration file online

It could be an endpoint, or a static JSON file, like this: https://petstore.swagger.io/v2/swagger.json.

IMPORTANT: Currently Swagger-UI only serves JSON format, should your configuration is in YAML format, convert it to JSON format instead.

2. Download necessary static swagger file

--

--

Kevin Mun
Learn AWS

I am always learning AWS, Flutter, Angular, Nodejs, Python. Full-time developer, husband, father, son, reader, and coffee drinker.