Skip to content

A powerful CLI tool that simplifies the deployment of static websites and Single Page Applications (SPAs) to AWS using S3 and CloudFront.

Notifications You must be signed in to change notification settings

youssefframy/aws-deploy-static-site

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Static Site Deployment Tool

A powerful CLI tool that simplifies the deployment of static websites and Single Page Applications (SPAs) to AWS using S3 and CloudFront.

Deploy SPA Demo

Features

  • 🚀 One-command deployment process
  • 🔒 Secure by default with CloudFront Origin Access Control
  • 📱 Support for both static websites and SPAs
  • 💨 Optimal caching configuration
  • 🌐 HTTPS enabled by default
  • 🎯 Interactive CLI interface

Quick Start

Option 1: Pre-built Binary

  1. Download the latest release for your platform:

  2. Configure AWS credentials using one of these methods:

    • AWS CLI: aws configure
    • Environment variables:
      export AWS_ACCESS_KEY_ID="your_access_key"
      export AWS_SECRET_ACCESS_KEY="your_secret_key"
    • IAM role (if running on AWS infrastructure)
  3. Run the executable and follow the interactive prompts

Option 2: Run Directly from Source

Prerequisites

  • Go 1.24 or later
  • AWS credentials configured
  • Required AWS permissions:
    • S3: CreateBucket, PutObject, PutBucketPolicy
    • CloudFront: CreateDistribution, CreateOriginAccessControl
    • IAM: GetUser

Installation & Usage

  1. Install Go (if not already installed):

  2. Clone and run the project:

# Clone the repository
git clone https://github.com/youssefframy/aws-deploy-static-site.git
cd aws-deploy-static-site

# Install dependencies
go mod tidy
go mod download

# Run directly with Go
go run main.go

Usage Guide

The tool provides an interactive CLI interface that will guide you through the deployment process:

  1. Select deployment type:

    • Static Website (Basic)
    • Single Page Application (SPA)
  2. Configure deployment settings:

    • AWS Profile (optional)
    • S3 Bucket Name
    • Website Files Location
    • CloudFront Distribution Description
    • AWS Region
  3. Wait for deployment completion (typically 10-15 minutes for CloudFront propagation)

Architecture

The deployment process:

  1. Creates a private S3 bucket
  2. Configures website hosting settings
  3. Uploads your static files with optimal caching headers
  4. Creates a CloudFront distribution with Origin Access Control
  5. Configures security policies and routing rules

Security Features

  • ✅ Private S3 bucket with public access blocked
  • ✅ CloudFront Origin Access Control (OAC)
  • ✅ HTTPS-only access
  • ✅ Secure IAM policies
  • ✅ Custom error handling for SPAs

Troubleshooting

Common issues and solutions:

  1. Access Denied

    • Verify AWS credentials are configured correctly
    • Ensure IAM user has required permissions
  2. Bucket Creation Failed

    • Check if bucket name is globally unique
    • Verify selected region supports all services
  3. Upload Issues

    • Confirm website folder path is correct
    • Check file permissions
  4. CloudFront Errors

    • Allow 10-15 minutes for distribution deployment
    • Verify domain name resolution

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For bugs and feature requests, please open an issue.

About

A powerful CLI tool that simplifies the deployment of static websites and Single Page Applications (SPAs) to AWS using S3 and CloudFront.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages