Stefano e25f8c1ecd
All checks were successful
AWS Deploy on Push / build (push) Successful in 1m3s
Run unit test upon committing new code
2025-05-28 23:41:12 -05:00
2025-05-28 21:52:39 -05:00
2025-05-28 23:31:04 -05:00
2025-05-28 21:52:39 -05:00
2025-05-13 18:13:40 -05:00
2025-05-21 16:57:27 -05:00

IPTV Updater AWS

An automated IPTV playlist and EPG updater service deployed on AWS infrastructure using CDK.

Overview

This project provides a service for automatically updating IPTV playlists and Electronic Program Guide (EPG) data. It runs on AWS infrastructure with:

  • EC2 instance for hosting the application
  • RDS PostgreSQL database for data storage
  • Amazon Cognito for user authentication
  • HTTPS support via Let's Encrypt
  • Domain management via FreeDNS

Prerequisites

  • AWS CLI installed and configured
  • Python 3.12 or later
  • Node.js v22.15 or later for AWS CDK
  • Docker and Docker Compose for local development

Local Development

  1. Clone the repository:
git clone <repo-url>
cd iptv-updater-aws
  1. Copy the example environment file:
cp .env.example .env
  1. Add your configuration to .env:
FREEDNS_User=your_freedns_username
FREEDNS_Password=your_freedns_password
DOMAIN_NAME=your.domain.name
SSH_PUBLIC_KEY=your_ssh_public_key
REPO_URL=repository_url
LETSENCRYPT_EMAIL=your_email
  1. Start the local development environment:
./scripts/start_local_dev.sh
  1. Stop the local environment:
./scripts/stop_local_dev.sh

Deployment

Initial Deployment

  1. Ensure your AWS credentials are configured:
aws configure
  1. Install dependencies:
pip install -r requirements.txt
  1. Deploy the infrastructure:
./scripts/deploy.sh

The deployment script will:

  • Create/update the CloudFormation stack using CDK
  • Configure the EC2 instance with required software
  • Set up HTTPS using Let's Encrypt
  • Configure the domain using FreeDNS

Continuous Deployment

The project includes a Gitea workflow (.gitea/workflows/aws_deploy_on_push.yml) that automatically:

  • Deploys infrastructure changes
  • Updates the application on EC2 instances
  • Restarts the service

Infrastructure

The AWS infrastructure is defined in infrastructure/stack.py and includes:

  • VPC with public subnets
  • EC2 t2.micro instance (Free Tier eligible)
  • RDS PostgreSQL database (db.t3.micro)
  • Security groups for EC2 and RDS
  • Elastic IP for the EC2 instance
  • Cognito User Pool for authentication
  • IAM roles and policies for EC2 instance access

User Management

Creating Users

To create a new user in Cognito:

./scripts/create_cognito_user.sh <user_pool_id> <username> <password> --admin <= optional for defining an admin user

Deleting Users

To delete a user from Cognito:

./scripts/delete_cognito_user.sh <user_pool_id> <username>

Architecture

The application is structured as follows:

app/
├── auth/           # Authentication modules
├── iptv/          # IPTV and EPG processing
├── models/        # Database models
└── utils/         # Utility functions

infrastructure/    # AWS CDK infrastructure code
docker/           # Docker configuration for local development
scripts/          # Utility scripts for deployment and management

Environment Variables

The following environment variables are required:

Variable Description
FREEDNS_User FreeDNS username
FREEDNS_Password FreeDNS password
DOMAIN_NAME Your domain name
SSH_PUBLIC_KEY SSH public key for EC2 access
REPO_URL Repository URL
LETSENCRYPT_EMAIL Email for Let's Encrypt certificates

Security Notes

  • The EC2 instance has appropriate IAM permissions for:
    • EC2 instance discovery
    • SSM command execution
    • RDS access
    • Cognito user management
  • All database credentials are stored in AWS Secrets Manager
  • HTTPS is enforced using Let's Encrypt certificates
  • Access is restricted through Security Groups
Description
No description provided
Readme 488 KiB
Languages
Python 95.9%
Shell 3.5%
Mako 0.3%
Dockerfile 0.3%