Deploy to AWS Free Tier

Deploy to a cloud platform (AWS Free Tier) — CI/CD foundations tutorial. Learn the core concept, hands-on steps, and troubleshooting tips to get your app live.

Focus: deploy to a cloud platform (aws free tier)

Sponsored

You’ve automated your tests, built your artifacts, and maybe even pushed a container image — but your app still isn’t reachable by anyone outside your laptop. That’s the gap this lesson closes. You’re about to deploy to a real cloud platform using AWS Free Tier, and by the end, you’ll have a live URL that proves your CI/CD pipeline works end-to-end.

The problem this lesson solves

Deploying to a cloud platform feels intimidating — there are dozens of services, pricing pages, and acronyms (EC2, S3, Elastic Beanstalk, Lambda). Without a clear path, developers often either skip deployment entirely or burn money on the wrong service.

The specific pain points we’re solving here:

  • Confusion about where to start — AWS has over 200 services; knowing which one fits a simple app is a genuine skill.
  • Fear of billing surprises — AWS Free Tier exists specifically so you can experiment without cost, but you need to understand its limits.
  • Manual deployment hell — uploading files by hand might work once, but it doesn’t scale and breaks the whole point of CI/CD.

By the end of this lesson, you’ll have deployed a small Python app to a production-like environment, using only resources that fall within the AWS Free Tier limits. You’ll also understand how this deployment fits into a CI/CD pipeline, so you can automate it in later lessons.

Core concept / mental model

Think of deployment as delivering your latest code to a server that anyone can reach. The server is like a rented house: you don’t own the building (the hardware), but you control what runs inside it (your app).

In AWS, the mental model looks like this:

  • EC2 (Elastic Compute Cloud) — a virtual machine in the cloud. Think of it as a small computer you can rent by the hour (but Free Tier gets you one for a year).
  • S3 (Simple Storage Service) — a place to store files, like a giant external hard drive. For static websites, S3 can even serve them directly.
  • Elastic Beanstalk — a higher-level service that hides the server management. You upload your code, and AWS handles the rest (load balancing, scaling, monitoring).

For a beginner, the simplest mental model is: "pick a server, copy your code, run your app, open the firewall." That’s it. Later you can upgrade to more sophisticated setups.

How it works step by step

Here’s the logical sequence you’ll follow when deploying to AWS Free Tier:

  1. Create an AWS account — you’ll need a credit card for verification, but you won’t be charged if you stay inside Free Tier limits.
  2. Choose a service — for a simple Python app, EC2 or Elastic Beanstalk are the most common. We’ll use EC2 for full control.
  3. Launch a virtual machine (instance) — select an Amazon Linux or Ubuntu AMI, choose the free t2.micro instance type.
  4. Connect to your instance — via SSH using your key pair.
  5. Install your app — copy your code, install dependencies, and run it with a process manager like systemd or pm2.
  6. Open the firewall (security group) — allow inbound traffic on port 8000 (or 80) so your app is reachable.
  7. Verify — visit your public IP in a browser.

Pro tip: Always check the region you launch in — Free Tier applies to t2.micro in any region, but some services have regional limits. Keep it simple and use the default region.

Hands-on walkthrough

Let’s get your app live. We’ll use a minimal Flask app as an example, but the same steps work for Django, FastAPI, or any Python web app.

Step 1: Prepare your app

Create a simple Flask app and a requirements.txt file locally:

# app.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return "Hello from AWS!"

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000)
# requirements.txt
flask==2.2.5

Step 2: Launch an EC2 instance

  • Go to the EC2 console and click Launch instance.
  • Choose Amazon Linux 2023 as the AMI.
  • Select the t2.micro instance type (it’s Free Tier eligible).
  • Create a new key pair (download the .pem file — you’ll need it to SSH).
  • In Network settings, click Edit and add a rule:
  • Type: Custom TCP
  • Port: 8000
  • Source: 0.0.0.0/0 (anywhere — fine for a demo)
  • Click Launch instance.

Step 3: SSH into your instance and deploy

Open a terminal and run:

chmod 400 your-key.pem
ssh -i your-key.pem ec2-user@<your-public-ip>

Now install Python and your app dependencies:

sudo yum update -y
sudo yum install python3-pip -y
pip3 install flask

Copy your app files to the instance using scp (in a new terminal from your local machine):

scp -i your-key.pem app.py requirements.txt ec2-user@<your-public-ip>:~

Back on the SSH session, run your app in the background:

python3 app.py

You should see:

 * Running on http://0.0.0.0:8000/

Step 4: Open the app in your browser

Go to http://<your-public-ip>:8000. You should see "Hello from AWS!" — your app is live!

Pro tip: If it doesn’t load, check that your security group has port 8000 open and that your app is listening on 0.0.0.0, not 127.0.0.1.

Compare options / when to choose what

Service Best for Free Tier limit Control level Maintenance effort
EC2 Custom apps, full control 750 hours/month of t2.micro High High (patches, updates)
Elastic Beanstalk Simple web apps, auto-scaling 750 hours/month of t2.micro Medium Low (AWS manages infra)
S3 (static site) Frontend, static content 5 GB storage, 20k GET requests Low Very low
Lambda Event-driven functions 1 million requests/month Very high Low (serverless)

Which should you choose?

  • EC2 is the best learning tool — you understand exactly what’s running and why. Start here.
  • Elastic Beanstalk is a great next step — plug your pipeline into it and deploy with eb deploy.
  • Lambda shines for APIs and small services, but has a different deployment pattern (functions, not apps).

Troubleshooting & edge cases

"Permission denied" when SSH-ing

If you see Permission denied (publickey), your key pair may have wrong permissions. Fix it:

chmod 400 your-key.pem

Port 8000 not reachable

One of these is likely off:

  • Security group — confirm the inbound rule exists and points to port 8000.
  • Firewall — some AMIs have firewalld or ufw enabled. On Amazon Linux, it’s usually off, but check with sudo systemctl status firewalld.
  • App binding — make sure app.run() uses host='0.0.0.0'.

Instance stops responding after a while

Free Tier instances stop if you don’t access them for a certain period, or if you restart via the console. Restart it and try again — the public IP may change if you don’t have an Elastic IP, so be ready to SSH to the new IP.

"pip3: command not found"

On fresh Amazon Linux, you may need to install pip:

sudo yum install python3-pip -y

Accidental charges

  • Always terminate instances when done (not just stop — termination releases the instance).
  • Check the Billing dashboard often during your first month.
  • Set up a billing alert for anything over $1.

What you learned & what's next

You’ve now deployed a Python app to a real cloud platform using AWS Free Tier. You can:

  • Explain the core idea behind cloud deployment: renting a server and putting your app on it.
  • Complete a practical exercise by launching an EC2 instance, installing your app, and making it accessible via the internet.
  • Compare deployment options (EC2 vs. Elastic Beanstalk vs. Lambda) and choose based on your needs.

This is a huge milestone. You’ve moved from running code locally to running it in the cloud — exactly what a CI/CD pipeline is meant to automate.

Next up in the CI/CD foundations track: You’ll connect this manual deployment to an automated pipeline. In the next lesson, you’ll set up GitHub Actions to run your tests, build your artifacts, and deploy to your EC2 instance automatically when you push to main. That’s where the real magic happens — the manual steps you just did will become one-command deploys. Stay sharp!

Practice recap

Now, take the Flask app you deployed and add a second endpoint (e.g., /health). Deploy it again to the same instance by copying the updated file and restarting the app. Then, in the AWS console, inspect the security group rules — try removing port 8000 and see if the site breaks. Restore it and note how the firewall controls access. This hands-on feel will make the next lesson on automation much easier to grasp.

Common mistakes

  • Leaving your security group open on port 22 (SSH) to the world — use a specific IP or a VPN, and always restrict with a custom rule.
  • Using the wrong instance type (e.g., t2.medium) — it’s not Free Tier eligible and will bill you.
  • Forgetting to set host='0.0.0.0' in your app — your app runs but isn't accessible from outside because it's bound to localhost.
  • Stopping but not terminating your EC2 instance — stopped instances still cost storage and keep your Free Tier hour count active.
  • Running your app in the foreground — close the SSH session and the app dies. Use nohup or a process manager like systemd.

Variations

  1. Use Elastic Beanstalk instead of EC2 for a fully managed deployment — no need to configure servers manually.
  2. Deploy a static site to S3 + CloudFront for ultra-low cost and high speed, especially for frontend-only projects.
  3. Use AWS Lambda + API Gateway for a serverless Python API — scale to zero when not in use, keeping Free Tier limits very predictable.

Real-world use cases

  • Host a personal portfolio site or blog on EC2 with a Flask app, connecting your GitHub repo for auto-deploys.
  • Deploy a REST API for a small business backend using Elastic Beanstalk, with an RDS database (also free tier) for data persistence.
  • Run a serverless cron-like job (e.g., a daily report generator) on Lambda, triggered by CloudWatch Events — almost no cost at Free Tier scale.

Key takeaways

  • AWS Free Tier provides a t2.micro instance for 750 hours/month — enough for a continuously running small app.
  • Deploying to EC2 involves launching an instance, SSH-ing in, copying your code, installing dependencies, and opening a security group port.
  • Always bind your app to 0.0.0.0 and open the right security group rule to make it accessible.
  • Compare EC2, Elastic Beanstalk, and Lambda to pick the right level of control vs. maintenance for your project.
  • Monitor your usage and terminate instances when done to avoid surprise charges; set billing alerts.
  • What you deployed manually here becomes automated in CI/CD — your next lesson will hook this up to GitHub Actions.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.