Skip to main content

๐Ÿš€ AWSUP - Lightning-fast AWS static website deployment

Project description

AWS Website Quick Deployer

A production-grade Python toolkit for deploying static websites to AWS using S3, CloudFront, Route53, and ACM. Now featuring modular architecture, comprehensive validation, and Infrastructure as Code support.

๐Ÿ†• Version 2.0 - Production Grade

New Features

  • Modular Architecture - Separated concerns with dedicated service managers
  • Configuration Management - Environment-based configs with validation
  • Enhanced Security - Input validation, secret detection, secure defaults
  • Infrastructure as Code - AWS CDK templates included
  • Rich CLI Experience - Beautiful terminal UI with progress indicators
  • Comprehensive Testing - Unit tests with pytest framework
  • Monitoring Ready - CloudWatch dashboard templates

๐Ÿš€ Quick Start

Production Deployment

# Install dependencies
pip install -r requirements.txt

# Initialize configuration
python deploy_production.py init yourdomain.com --region us-east-1

# Deploy with validation and monitoring
python deploy_production.py phase1 yourdomain.com
python deploy_production.py phase2 yourdomain.com --website-path ./dist

# OR: Complete deployment in one command
python deploy_production.py deploy yourdomain.com --website-path ./dist

# Check status
python deploy_production.py status yourdomain.com

Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Route53       โ”‚    โ”‚   ACM           โ”‚    โ”‚   CloudFront    โ”‚
โ”‚   DNS Records   โ”‚โ”€โ”€โ”€โ–ถโ”‚   SSL Cert      โ”‚โ”€โ”€โ”€โ–ถโ”‚   CDN           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                        โ”‚
                                                        โ–ผ
                                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                              โ”‚   S3 Bucket     โ”‚
                                              โ”‚   Static Files  โ”‚
                                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Prerequisites

  1. AWS Account with appropriate permissions
  2. Python 3.8+ installed
  3. AWS CLI configured with credentials
  4. Domain name (registered with any registrar)

Required AWS Permissions

Create an IAM policy with these permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "route53:*",
        "s3:*", 
        "cloudfront:*",
        "acm:*",
        "sts:GetCallerIdentity"
      ],
      "Resource": "*"
    }
  ]
}

Installation

Production Setup

git clone https://github.com/Akramovic1/aws-website-quick-deployer.git
cd aws-website-quick-deployer
pip install -r requirements.txt

Quick Setup

# Clone and install
git clone https://github.com/Akramovic1/aws-website-quick-deployer.git
cd aws-website-quick-deployer
pip install boto3 botocore rich click

Quick Start

Default Behavior (Recommended)

Simply run the script with your domain name - it will handle both phases with a pause for NS configuration:

# Run complete deployment with automatic pause for NS configuration
python aws_deploy.py yourdomain.com

# With website files
python aws_deploy.py yourdomain.com --website-path ./dist

# Without website files (uses default Coming Soon page)
python aws_deploy.py yourdomain.com

The script will:

  1. Create Route53 hosted zone
  2. Display NS records
  3. Wait for you to configure nameservers at your registrar
  4. Continue with full deployment after confirmation
  5. Deploy your website or default Coming Soon page

Usage Guide

Method 1: Automatic Two-Phase Deployment (Default)

python aws_deploy.py yourdomain.com

This will:

  • Run Phase 1 (Route53 setup)
  • Display NS records for you to configure
  • Pause and wait for your confirmation
  • Run Phase 2 (complete deployment)

Method 2: Manual Phase Control

Phase 1: Setup Route53 (Get NS Records)

python aws_deploy.py yourdomain.com --phase1

Example output:

============================================================
IMPORTANT: Configure your domain registrar
============================================================

Domain: yourdomain.com

Nameservers to configure at your registrar (e.g., GoDaddy):

  NS1: ns-123.awsdns-12.com
  NS2: ns-456.awsdns-34.net
  NS3: ns-789.awsdns-56.org
  NS4: ns-012.awsdns-78.co.uk

============================================================
Copy these nameservers to your domain registrar's DNS settings
Wait 5-30 minutes for DNS propagation before running Phase 2
============================================================

Configure Domain Registrar

  1. Log into your domain registrar (GoDaddy, Namecheap, etc.)
  2. Go to DNS settings for your domain
  3. Change nameservers from default to custom
  4. Enter the 4 NS records provided by the script
  5. Save changes and wait 5-30 minutes for propagation

Phase 2: Complete Deployment

python aws_deploy.py yourdomain.com --phase2 --website-path ./dist

Method 3: One-Command Deployment (NS Already Configured)

If NS records are already configured or you're re-deploying:

python aws_deploy.py yourdomain.com --deploy --website-path ./dist

Command Options

Deployment Commands

# DEFAULT: Run both phases with pause for NS configuration
python aws_deploy.py yourdomain.com
python aws_deploy.py yourdomain.com --website-path ./website

# Phase 1 only - Get NS records
python aws_deploy.py yourdomain.com --phase1

# Phase 2 only - Complete deployment
python aws_deploy.py yourdomain.com --phase2 --website-path ./website

# Both phases without pause (if NS already configured)
python aws_deploy.py yourdomain.com --deploy --website-path ./website

# Deploy without uploading files (uses default Coming Soon page)
python aws_deploy.py yourdomain.com --phase2

Cleanup Commands

# Remove Phase 1 resources (Route53 hosted zone)
python aws_deploy.py yourdomain.com --cleanup-phase1

# Remove Phase 2 resources (S3, CloudFront, ACM)
python aws_deploy.py yourdomain.com --cleanup-phase2

# Remove all resources
python aws_deploy.py yourdomain.com --cleanup-all

Utility Commands

# Invalidate CloudFront cache
python aws_deploy.py yourdomain.com --invalidate-cache

# Show current deployment state
python aws_deploy.py yourdomain.com --show-state

# Specify AWS region (default: us-east-1)
python aws_deploy.py yourdomain.com --region us-west-2

Website File Structure

Your website files should be organized like:

website/
โ”œโ”€โ”€ index.html          # Required - default page
โ”œโ”€โ”€ 404.html           # Optional - error page
โ”œโ”€โ”€ css/
โ”‚   โ””โ”€โ”€ styles.css
โ”œโ”€โ”€ js/
โ”‚   โ””โ”€โ”€ script.js
โ”œโ”€โ”€ images/
โ”‚   โ””โ”€โ”€ logo.png
โ””โ”€โ”€ favicon.ico

Default Coming Soon Page

If no website files are provided, the script automatically deploys a professional "Coming Soon" landing page featuring:

  • Responsive modern design
  • Animated gradient background
  • Progress indicator
  • Email collection form
  • Social media links
  • Mobile-optimized layout

To customize the default page, place default-index.html in the same directory as the script.

State Management

The script maintains state in a hidden JSON file (.yourdomain.com_deployment_state.json) to track:

  • Hosted Zone ID
  • NS Records
  • Certificate ARN
  • S3 Bucket Name
  • CloudFront Distribution ID
  • Distribution Domain

This allows the script to:

  • Resume interrupted deployments
  • Reuse existing resources
  • Perform intelligent updates
  • Clean up resources properly

Error Handling

The script includes comprehensive error handling for:

  • Existing Resources: Automatically detects and reuses existing resources
  • Conflicting Records: Removes conflicting DNS records automatically
  • Certificate Validation: Handles DNS validation with automatic record creation
  • Bucket Naming: Handles bucket name conflicts
  • CloudFront State: Properly disables distributions before deletion
  • Partial Deployments: Can resume from any point using state file

Best Practices Implemented

  1. Security

    • S3 buckets are private (no public access)
    • CloudFront uses Origin Access Control (OAC)
    • TLS 1.2+ enforced
    • Bucket encryption enabled
  2. Performance

    • CloudFront CDN for global distribution
    • HTTP/2 and HTTP/3 support
    • Compression enabled
    • Optimized cache policies
  3. Reliability

    • Versioning enabled on S3 buckets
    • Custom error pages configured
    • IPv6 support enabled
  4. Cost Optimization

    • Reuses existing resources
    • Proper resource tagging
    • Efficient CloudFront price class

Troubleshooting

Common Issues

DNS Not Resolving

  • Ensure NS records are correctly configured at registrar
  • Wait up to 48 hours for full propagation
  • Use nslookup or dig to verify: dig yourdomain.com NS

Access Denied Errors

  • Check S3 bucket policy has correct account ID and distribution ID
  • Ensure CloudFront OAC is properly configured
  • Verify bucket name matches domain exactly

Certificate Validation Failed

  • Check DNS validation records were created
  • Ensure Route53 hosted zone is authoritative
  • May take up to 30 minutes for validation

CloudFront Not Updating

  • Create cache invalidation: python aws_deploy.py yourdomain.com --invalidate-cache
  • Wait 15-20 minutes for distribution changes to deploy

Verification Steps

After deployment, verify:

  1. HTTPS Access: https://yourdomain.com
  2. WWW Redirect: https://www.yourdomain.com
  3. SSL Certificate: Check browser padlock icon
  4. CloudFront Cache: Check response headers for x-cache: Hit from CloudFront

Cost Estimates

Monthly costs (approximate):

  • Route53: $0.50 per hosted zone + $0.40 per million queries
  • S3: ~$0.023 per GB stored + $0.0004 per 1,000 requests
  • CloudFront: ~$0.085 per GB transferred (varies by region)
  • ACM: Free for certificates used with CloudFront

For a small website (<1GB, <100GB transfer/month): ~$5-10/month

Advanced Configuration

Custom Error Pages

The script automatically configures:

  • 404 errors โ†’ /404.html (if exists)
  • 403 errors โ†’ /index.html (for SPA routing)

Cache Invalidation

To update content immediately:

python aws_deploy.py yourdomain.com --invalidate-cache

Multiple Environments

For staging/production:

# Staging
python aws_deploy.py staging.yourdomain.com --website-path ./dist-staging

# Production
python aws_deploy.py yourdomain.com --website-path ./dist-production

Security Considerations

  1. AWS Credentials: Never commit AWS credentials. Use AWS CLI configuration or environment variables
  2. State Files: Add .*_deployment_state.json to .gitignore
  3. Bucket Policies: Script automatically configures secure policies
  4. HTTPS Only: HTTP automatically redirects to HTTPS

๐Ÿ—๏ธ Production Features

Modular Architecture

src/
โ”œโ”€โ”€ deployer/
โ”‚   โ”œโ”€โ”€ config.py          # Configuration management
โ”‚   โ”œโ”€โ”€ validators.py      # Input & security validation
โ”‚   โ””โ”€โ”€ managers/          # AWS service managers
โ”‚       โ”œโ”€โ”€ route53.py     # DNS operations
โ”‚       โ”œโ”€โ”€ s3.py          # Storage operations  
โ”‚       โ”œโ”€โ”€ acm.py         # Certificate operations
โ”‚       โ””โ”€โ”€ cloudfront.py  # CDN operations
โ”œโ”€โ”€ infrastructure/cdk/    # Infrastructure as Code
โ””โ”€โ”€ tests/                 # Unit tests

Configuration Management

Create environment-specific configurations:

# Development
python deploy_production.py init dev.yourdomain.com --environment dev

# Production  
python deploy_production.py init yourdomain.com --environment prod

Infrastructure as Code

Deploy using AWS CDK for reproducible infrastructure:

cd src/infrastructure/cdk
cdk deploy WebsiteStack --context domain=yourdomain.com

Security Features

  • Input validation for domains, files, and configurations
  • Secret detection in files and environment variables
  • Secure defaults with minimal privileges
  • Security scanning of uploaded content

Monitoring & Observability

  • CloudWatch dashboards for traffic and performance metrics
  • Structured logging with rich terminal output
  • Resource tagging for cost tracking and management
  • State tracking for deployment visibility

๐Ÿงช Testing

Quick Test Run

# Install dependencies and run tests
pip install -r requirements.txt
python -m pytest tests/ -v

Comprehensive Testing

# Run all tests with coverage
make test-cov

# Run specific test types
make test-unit           # Unit tests only
make test-security       # Security tests + bandit scan

# Code quality checks
make lint               # Linting with flake8 and mypy
make format             # Format code with black and isort
make security           # Security scanning with bandit

Using Makefile

# See all available commands
make help

# Development setup
make dev-setup

# Quick development testing
make dev-test

# Full validation
make validate test lint security

Test Results

All tests should pass:

============================= test session starts =============================
collected 9 items

tests/test_validators.py::TestDomainValidator::test_valid_domains PASSED
tests/test_validators.py::TestDomainValidator::test_invalid_domains PASSED  
tests/test_validators.py::TestDomainValidator::test_domain_normalization PASSED
tests/test_validators.py::TestFileValidator::test_validate_html_file PASSED
tests/test_validators.py::TestFileValidator::test_validate_large_file PASSED
tests/test_validators.py::TestFileValidator::test_validate_directory_with_index PASSED
tests/test_validators.py::TestFileValidator::test_validate_directory_without_index PASSED
tests/test_validators.py::TestAWSValidator::test_valid_regions PASSED
tests/test_validators.py::TestAWSValidator::test_bucket_name_validation PASSED

============================== 9 passed in 0.82s ==============================

๐Ÿ“Š Monitoring

Deploy CloudWatch dashboard:

aws cloudwatch put-dashboard \
  --dashboard-name "Website-${DOMAIN}" \
  --dashboard-body file://monitoring/cloudwatch_dashboard.json

Monitor key metrics:

  • CloudFront: Requests, errors, cache hit ratio
  • S3: Storage usage, request counts
  • Route53: DNS query volume
  • ACM: Certificate status

Support and Contributing

For issues, feature requests, or contributions:

  1. Check existing issues in the GitHub repository
  2. Provide detailed error messages and logs
  3. Include AWS region, domain, and deployment mode
  4. Use the issue templates provided

License

MIT License - Feel free to use and modify for your needs.

Changelog

See CHANGELOG.md for version history and updates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awsup-2.0.0.tar.gz (52.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awsup-2.0.0-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

Details for the file awsup-2.0.0.tar.gz.

File metadata

  • Download URL: awsup-2.0.0.tar.gz
  • Upload date:
  • Size: 52.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for awsup-2.0.0.tar.gz
Algorithm Hash digest
SHA256 51343229ed8796b0fec1dea0b204a57f3ead67aaaaf0165e5c95d38968c627fb
MD5 669f426cefc278ad9a66b759328b3038
BLAKE2b-256 dd42fef1bf54f63d4bd67920118aeb95bc93c0f92865b99954dd9ad83e91683f

See more details on using hashes here.

File details

Details for the file awsup-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: awsup-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for awsup-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 077c6db4b7e917f03382039d197637144c21371362cb1e20e905d3700530d9c1
MD5 c57e1f98997237b40af41c3a92859dc3
BLAKE2b-256 ce9c62889d291cebab3e3a6e19d2f7c51a2411dc2179c3a43c0f0e691ae85ded

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page