Deploy OpenAPI Documentation with AWS Amplify

AWS Amplify console showing deployed OpenAPI documentation site

I choose the AWS Amplify for deploying OpenAPI Static Website.

It is very simple.

Step 1. Create a Repo

VS Code showing an HTML page that loads an OpenAPI spec with Swagger UI

I have only 2 files in my repo.

  • index.html
  • api.yml

You can follow the official guide.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="SwaggerUI" />
<title>SwaggerUI</title>
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css" />
</head>
<body>
<div id="swagger-ui"></div>
https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js
<script>
window.onload = () => {
window.ui = SwaggerUIBundle({
url: './api.yml',
dom_id: '#swagger-ui',
});
};
</script>
</body>
</html>

This is my index.html file.

Step 2. Create an Amplify Project

AWS Amplify homepage with the Deploy an app button selected
AWS Amplify app setup with GitHub selected as the source code provider

Login AWS, Search Amplify and Create a new App.

  • Don’t select template (e.g, Next.js, Due, Angular and Vite. We don’t need it)

And Select your GitHub Repository and Branch. (You don’t need to make your Repo as Public, Private Repo also is working fine)

AWS Amplify app settings with password protection enabled

Protect your site if you want

  • Set an Username and Password
AWS Amplify review page with the Save and deploy button selected

Ok, that’s all. Click Save and deploy!

AWS Amplify app overview showing the main branch deployment URL

Click Monitoring and check your Domain. Open this url.

Browser sign-in prompt for a password-protected AWS Amplify site

If you set Username and Password, You must Sign In to access your Website

Deployed Swagger UI showing TravelCrumb API endpoints

All done, Your OpenAPI Document Site is Live now!

Step 3. Set Up a Custom Domain

If you want to set your custom domain for your website, follow this guidelines

AWS Amplify custom domain setup with a Route 53 domain selected

I recommend Route53. If your domain already registered in Route53, setup custom domain is very easy.

AWS Amplify configuring an OpenAPI subdomain and managed SSL certificate

Enter your subdomains. And Click Add domain button.

AWS Amplify custom domain page showing SSL certificate creation in progress

It takes 2-3 minutes. Just wait a bit. You will access your static website using your subdomain.

Conclusion

Using Amplify is super simple to deploy the static website. You don’t need to extra setup. When your branch has updated, amplify will automatically detect that changes and deploy it.

Next topic, I’ll share how to verify OpenAPI spec file using IBM OpenAPI Validator. https://github.com/IBM/openapi-validator

Related Post

Comments

One response to “Deploy OpenAPI Documentation with AWS Amplify”

  1. […] From OpenAPI Spec to Live Documentation: AWS Amplify Deploy Guide […]

Leave a Reply

Discover more from Shawn

Subscribe now to keep reading and get access to the full archive.

Continue reading