๐ 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
- AWS Account with appropriate permissions
- Python 3.8+ installed
- AWS CLI configured with credentials
- 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:
- Create Route53 hosted zone
- Display NS records
- Wait for you to configure nameservers at your registrar
- Continue with full deployment after confirmation
- 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
- Log into your domain registrar (GoDaddy, Namecheap, etc.)
- Go to DNS settings for your domain
- Change nameservers from default to custom
- Enter the 4 NS records provided by the script
- 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
-
Security
- S3 buckets are private (no public access)
- CloudFront uses Origin Access Control (OAC)
- TLS 1.2+ enforced
- Bucket encryption enabled
-
Performance
- CloudFront CDN for global distribution
- HTTP/2 and HTTP/3 support
- Compression enabled
- Optimized cache policies
-
Reliability
- Versioning enabled on S3 buckets
- Custom error pages configured
- IPv6 support enabled
-
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
nslookupordigto 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:
- HTTPS Access:
https://yourdomain.com - WWW Redirect:
https://www.yourdomain.com - SSL Certificate: Check browser padlock icon
- 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
- AWS Credentials: Never commit AWS credentials. Use AWS CLI configuration or environment variables
- State Files: Add
.*_deployment_state.jsonto.gitignore - Bucket Policies: Script automatically configures secure policies
- 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:
- Check existing issues in the GitHub repository
- Provide detailed error messages and logs
- Include AWS region, domain, and deployment mode
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51343229ed8796b0fec1dea0b204a57f3ead67aaaaf0165e5c95d38968c627fb
|
|
| MD5 |
669f426cefc278ad9a66b759328b3038
|
|
| BLAKE2b-256 |
dd42fef1bf54f63d4bd67920118aeb95bc93c0f92865b99954dd9ad83e91683f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
077c6db4b7e917f03382039d197637144c21371362cb1e20e905d3700530d9c1
|
|
| MD5 |
c57e1f98997237b40af41c3a92859dc3
|
|
| BLAKE2b-256 |
ce9c62889d291cebab3e3a6e19d2f7c51a2411dc2179c3a43c0f0e691ae85ded
|