AWS Builder Center

Building and deploying a Time-Aware Recipe web app on Amazon LighSail Container Service with Github Actions

Learn how to build "Whats cooking now?" a containerized python web application ,and automate its deployment to Amazon LightSail Container Service using Github actions CI/CD

๐Ÿฝ๏ธ What's Cooking Now?

A time-based recipe web app that suggests the perfect recipe based on your current time of day โ€” built with Flask, HTML, CSS & JS, containerized with Docker, and deployed on Amazon Lightsail via GitHub Actions CI/CD.
๏ปฟ

๏ปฟ

๐Ÿ“ธ Preview

Time of Day
Recipe Suggested
๐ŸŒ… 6AM โ€“ 11AM
Avocado Toast with Poached Eggs
โ˜€๏ธ 11AM โ€“ 1PM
Fluffy Banana Pancakes
๐ŸŒž 1PM โ€“ 4PM
Grilled Chicken Caesar Wrap
๐ŸŒ† 4PM โ€“ 7PM
Honey Garlic Popcorn
๐ŸŒ™ 7PM โ€“ 10PM
Creamy Tuscan Garlic Pasta
๐ŸŒƒ 10PM โ€“ 6AM
Midnight Nutella Mug Cake

๏ปฟ

๐Ÿ“ Project Structure

whats-cooking-now/
โ”œโ”€โ”€ app.py # Flask backend โ€” API routes & recipe logic
โ”œโ”€โ”€ Dockerfile # Docker container configuration
โ”œโ”€โ”€ requirements.txt # Python dependencies
โ”œโ”€โ”€ static/
โ”‚ โ”œโ”€โ”€ index.html # Frontend HTML
โ”‚ โ”œโ”€โ”€ style.css # Styling & animations
โ”‚ โ””โ”€โ”€ script.js # Frontend logic & API calls
โ””โ”€โ”€ .github/
โ””โ”€โ”€ workflows/
โ””โ”€โ”€ deploy.yml # GitHub Actions CI/CD pipeline

๏ปฟ
๏ปฟ
---

๐Ÿ› ๏ธ Tech Stack

Technology
Purpose
Python 3.11
Backend language
Flask 3.0.3
Web framework & REST API
HTML5
Frontend structure
CSS3
Styling, animations, responsive design
JavaScript (Vanilla)
Live clock, API calls, countdown timer
Docker
Containerization
Amazon Lightsail
Cloud hosting (container service)
GitHub Actions
CI/CD pipeline โ€” auto deploy on push
AWS IAM
Secure access management for deployment

๏ปฟ

๐Ÿš€ Quick Start โ€” Run Locally

Prerequisites

  • Python 3.11+
  • pip
  • Docker (optional, for container testing)
  • Git

Option 1 โ€” Run with Python directly

# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/whats-cooking-now.git
cd whats-cooking-now
# 2. Install dependencies
pip install flask
# 3. Start Flask
python app.py
# 4. Open in browser
# โ†’ http://localhost:5000

Option 2 โ€” Run with Docker

# 1. Build the Docker image
docker build -t whats-cooking-now .
# 2. Run the container
docker run -p 5000:5000 whats-cooking-now
# 3. Open in browser
# โ†’ http://localhost:5000

๏ปฟ

๐Ÿ”— API Endpoints

Method
Endpoint
Description
GET
ย /ย 
Serves the frontend app
GET
ย /api/recipeย 
Returns recipe based on current time
GET
ย /api/recipe/breakfastย 
Returns breakfast recipe
GET
ย /api/recipe/brunchย 
Returns brunch recipe
GET
ย /api/recipe/lunchย 
Returns lunch recipe
GET
ย /api/recipe/snackย 
Returns snack recipe
GET
ย /api/recipe/dinnerย 
Returns dinner recipe
GET
ย /api/recipe/midnightย 
Returns midnight recipe

Sample Response

{
"meal_time": "dinner",
"current_hour": 20,
"recipe": {
"emoji": "๐ŸŒ™",
"meal": "Creamy Tuscan Garlic Pasta ๐Ÿ๐Ÿง„",
"time_range": "7 PM โ€“ 10 PM",
"ingredients": [
"300g fettuccine pasta",
"3 cloves garlic",
"1 cup heavy cream",
"ยฝ cup sun-dried tomatoes",
"2 cups spinach",
"Parmesan cheese",
"Olive oil, salt, pepper"
],
"steps": [
"Cook pasta according to package instructions.",
"Sautรฉ garlic in olive oil for 2 minutes.",
"..."
],
"fun_fact": "Italy has over 350 different pasta shapes! ๐Ÿ‡ฎ๐Ÿ‡น"
}
}

๏ปฟ

โ˜๏ธ AWS Services Used

1. ๐ŸŸ  Amazon Lightsail โ€” Container Service

What it is: Amazon Lightsail is AWS's simplified cloud platform designed for developers who need to deploy apps quickly without managing complex infrastructure. It bundles compute, networking, and storage into simple, predictable monthly pricing.
What we used:
  • Lightsail Container Service โ€” a fully managed environment to run Docker containers
  • Power: ย nanoย  (512MB RAM, 0.25 vCPU) โ€” perfect for small apps
  • Scale: 1 node
  • Auto-generated HTTPS public endpoint URL
How it works in this project:
GitHub push โ†’ GitHub Actions builds Docker image
โ†’ Pushes image to Lightsail
โ†’ Creates deployment
โ†’ App is live at HTTPS URL
Lightsail Container Service URL format:
https://<service-name>.<random-id>.<region>.cs.amazonlightsail.com
Pricing:
  • Nano plan: ~$7/month
  • Billed hourly โ€” delete when not in use to avoid charges

๏ปฟ

2. ๐Ÿ” AWS IAM โ€” Identity and Access Management

What it is: AWS IAM lets you securely control who can access your AWS resources and what actions they can perform. It follows the principle of least privilege โ€” give only the permissions needed, nothing more.
What we used:
  • Created a dedicated IAM user specifically for GitHub Actions
  • Attached the ย AmazonLightsailFullAccessย  policy
  • Generated Access Key ID and Secret Access Key for programmatic access
Why not use root account keys?
โŒ Root account has unlimited access to everything in your AWS account. If leaked, an attacker can delete all your resources, rack up huge bills, or steal data. Always use IAM users with limited permissions.
IAM User Setup Steps:
  1. Go to IAM Console โ†’ Users โ†’ Create User
  1. Username: ย github-actions-lightsailย 
  1. Select: "Attach policies directly"
  1. Attach: ย AmazonLightsailFullAccessย 
  1. Go to user โ†’ Security credentials โ†’ Create access key
  1. Select: "Application running outside AWS"
  1. Save the Access Key ID and Secret Access Key โ€” shown only once!

๏ปฟ

3. ๐Ÿ™ GitHub Actions โ€” CI/CD Pipeline

What it is: GitHub Actions is a CI/CD (Continuous Integration / Continuous Deployment) platform built into GitHub. It automatically runs workflows when you push code โ€” in our case, it builds and deploys the app to Lightsail on every push to ย mainย .
What we used:
  • Workflow file: ย .github/workflows/deploy.ymlย 
  • Trigger: Push to ย mainย  branch
  • Jobs: Build Docker image โ†’ Push to Lightsail โ†’ Deploy โ†’ Print URL
Workflow Steps Explained:
Step
What it does
ย actions/checkout@v4ย 
Pulls your code into the runner
ย aws-actions/configure-aws-credentials@v4ย 
Authenticates with AWS using your secrets
Install ย lightsailctlย 
Installs the Lightsail CLI plugin for pushing images
ย docker buildย 
Builds your Docker image locally on the runner
ย create-container-serviceย 
Creates Lightsail service if it doesn't exist yet
Wait loop
Polls until service state is READY or RUNNING
ย push-container-imageย 
Uploads Docker image to Lightsail
ย create-container-service-deploymentย 
Deploys the new image live
Print URL
Outputs the live app URL in the logs
GitHub Secrets Required:
Secret Name
Description
ย AWS_ACCESS_KEY_IDย 
IAM user access key
ย AWS_SECRET_ACCESS_KEYย 
IAM user secret key
ย AWS_REGIONย 
AWS region e.g. ย us-east-1ย 
ย LIGHTSAIL_SERVICE_NAMEย 
Your service name e.g. ย whats-cooking-nowย 
How to add secrets: GitHub Repo โ†’ Settings โ†’ Secrets and variables โ†’ Actions โ†’ New repository secret

๏ปฟ

4. ๐Ÿณ Docker โ€” Containerization

What it is: Docker packages your application and all its dependencies into a container โ€” a lightweight, portable unit that runs the same way everywhere: your laptop, a teammate's machine, or AWS.
Our Dockerfile explained:
FROM python:3.11-slim # Use lightweight Python 3.11 base image
WORKDIR /app # Set working directory inside container
COPY requirements.txt . # Copy dependencies file first (layer caching)
RUN pip install --no-cache-dir -r requirements.txt # Install dependencies
COPY . . # Copy all project files
EXPOSE 5000 # Tell Docker the app runs on port 5000
CMD ["python", "app.py"] # Command to start the Flask app
Useful Docker commands:
# Build image
docker build -t whats-cooking-now .
# Run container
docker run -p 5000:5000 whats-cooking-now
# Run in background
docker run -d -p 5000:5000 whats-cooking-now
# List running containers
docker ps
# Stop container
docker stop <container-id>
# Remove image
docker rmi whats-cooking-now

๏ปฟ

๐Ÿ”ง Full Deployment Setup Guide

Step 1 โ€” Create IAM User
  1. Open IAM Console
  1. Create user: ย github-actions-lightsailย 
  1. Attach policy: ย AmazonLightsailFullAccessย 
  1. Create access key โ†’ save both keys
Step 2 โ€” Add GitHub Secrets
  1. Go to your GitHub repo โ†’ Settings โ†’ Secrets and variables โ†’ Actions
  1. Add these 4 secrets:
  • ย AWS_ACCESS_KEY_IDย 
  • ย AWS_SECRET_ACCESS_KEYย 
  • ย AWS_REGIONย  (e.g. ย us-east-1ย )
  • ย LIGHTSAIL_SERVICE_NAMEย  (e.g. ย whats-cooking-nowย )
Step 3 โ€” Push to GitHub
git init
git add .
git commit -m "Initial commit โ€” What's Cooking Now"
git branch -M main
git remote add origin https://github.com/Santhosh-p653/aws-lightsail.git
git push -u origin main
Step 4 โ€” Watch GitHub Actions Deploy
  1. Go to your repo โ†’ Actions tab
  1. Watch the workflow run in real time
  1. When complete, click the last step "Get App URL"
  1. Copy your live HTTPS URL ๐ŸŽ‰
Step 5 โ€” Open Your Live App
https://whats-cooking-now.xxxxxxxx.<region>.cs.amazonlightsail.com

๏ปฟ

๐Ÿงช Testing the API Locally

# Current time recipe
curl http://localhost:5000/api/recipe
# Specific meal
curl http://localhost:5000/api/recipe/dinner
# Pretty print
curl http://localhost:5000/api/recipe | python -m json.tool
# Test invalid (should return 404)
curl -i http://localhost:5000/api/recipe/pizza

๏ปฟ

๐Ÿงน Cleanup Guide

Disable (Pause โ€” keeps data, stops compute charges)
aws lightsail update-container-service \
--service-name whats-cooking-now \
--is-disabled
Full Delete (Permanent โ€” cannot be undone)
aws lightsail delete-container-service \
--service-name whats-cooking-now
Or via Console: Lightsail Console โ†’ Click service โ†’ Three dots menu โ†’ Delete
Full Cleanup Checklist
  • โœ… Delete Lightsail container service
  • โœ… Delete IAM user (ย github-actions-lightsailย )
  • โœ… Remove GitHub repository secrets
  • โœ… Delete any unused Lightsail Static IPs
  • โœ… Delete any Lightsail snapshots
โš ๏ธ Static IPs are billed even when unattached โ€” always check Lightsail Networking.

๏ปฟ

๐Ÿ› Troubleshooting

Problem
Fix
CSS/JS not loading
Make sure paths are ย /static/style.cssย  and ย /static/script.jsย 
404 on ย /api/recipeย 
Flask is not running โ€” check ย python app.pyย 
Docker build fails
Check ย requirements.txtย  exists in root folder
GitHub Actions fails at AWS step
Verify all 4 GitHub Secrets are set correctly
Lightsail service stuck in PENDING
Wait 2โ€“3 minutes, it's provisioning for the first time
App URL returns 503
Service is disabled โ€” re-enable from Lightsail console

๏ปฟ

๐Ÿ“„ License

MIT License โ€” free to use, modify, and distribute.

๏ปฟ

๐Ÿ™Œ Built With

  • AWS IAM โ€” Secure access management

๏ปฟ
๐Ÿ’ก Tip: Star โญ this repo if you found it helpful!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article