Menu

1 / 2

How I Deployed FastAPI to EC2 with HTTPS Using API Gateway

DEV Community·Lia·6 months ago
#T1t8Egi9
#api#aws#python#fullscreen#docker
Reading 0:00
15s threshold

Intro

I wanted to deploy my FastAPI backend on AWS EC2 and get a proper HTTPS URL without dealing with SSL certificates manually. Turns out API Gateway handles all of that for you — but getting there wasn't as smooth as I expected. Here's everything I went through, including the parts where I got stuck.

EC2 instance setup is covered in my previous post, so I'll skip that part here!

Overview

FastAPI App ↓ Dockerize & deploy on EC2 ↓ Connect API Gateway ↓ HTTPS URL ready to go

Enter fullscreen mode

Exit fullscreen mode

Step 1. Elastic IP

The Elastic IP was provided by our organization, so I just attached it to the instance.

Without an Elastic IP, your EC2 public IP changes every time you restart the instance — which means you'd have to update your API Gateway integration every single time.

Step 2.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.