tool-s3-cloudfront-push

A shell-based static site deployer that crawls a running local website and pushes it to AWS S3 and CloudFront for low-cost, HTTPS-enabled global hosting.

https://github.com/davidbmar/tool-s3-cloudfront-push  ·  public  ·  shipped

What it is

A collection of Bash scripts that automate the deployment of dynamic or locally-hosted websites to AWS infrastructure. It converts a running site (e.g., localhost:3000) into static files via crawling, then uploads them to a private S3 bucket served through a CloudFront CDN with Origin Access Control (OAC) for security and HTTPS.

Features

Quickstart

./step0-setup-aws-account.sh
./step1-crawl-site.sh
./step2-create-infrastructure.sh
./step3-deploy.sh

Architecture

flowchart TD
    User[User/Laptop] -->|Runs Scripts| Scripts[Bash Scripts]
    Scripts -->|Crawls| LocalSite[Running Website localhost]
    LocalSite -->|Static Files| CrawlOutput[crawl-output/]
    Scripts -->|Uploads| CrawlOutput
    CrawlOutput -->|AWS CLI PutObject| S3[(S3 Bucket Private)]
    S3 -->|Origin Access Control| CF[CloudFront Distribution]
    CF -->|HTTPS| Visitor[Global Visitors]

How it's built

The project is built entirely in Shell (Bash). It relies on standard Unix utilities for file handling and the AWS CLI for interacting with Amazon Web Services (S3, CloudFront, IAM). It uses `wget` or similar tools implicitly for the crawling step to generate static copies of dynamic pages.

How it runs

sequenceDiagram
    participant U as User
    participant S as Shell Scripts
    participant L as Local Site
    participant AWS as AWS CLI
    participant S3 as S3 Bucket
    participant CF as CloudFront

    U->>S: Execute step1-crawl-site.sh
    S->>L: Request pages/assets
    L-->>S: Return HTML/CSS/JS
    S->>S: Save to crawl-output/
    
    U->>S: Execute step3-deploy.sh
    S->>AWS: Upload files
    AWS->>S3: PutObject (Private)
    S->>AWS: Create Invalidation
    AWS->>CF: Invalidate Cache
    CF-->>U: Serve updated content via HTTPS

How to apply & reuse

Use this tool when you have a website running locally (or on a staging server) that you want to publish as a static site with minimal ongoing cost. It is ideal for portfolios, blogs, or documentation sites where server-side processing is not required at runtime, but you want the performance and security of a CDN.

At a glance

CapabilitiesStatic site generation via crawlingAWS infrastructure provisioningSecure cloud storage deploymentCDN cache managementIAM credential management
Componentsstep0-setup-aws-account.shstep1-crawl-site.shstep2-create-infrastructure.shstep3-deploy.shcrawl-output directory
TechBashAWS CLIWget/CurlJSON
Depends onAWS AccountAWS CLI installed and configuredUnix-like operating systemInternet connection
Integrates withAmazon S3Amazon CloudFrontAWS IAMLocal Web Servers
PatternsStatic Site GenerationInfrastructure as Code (Scripted)CI/CD Pipeline (Manual)Least Privilege Access
Reuse tagsdeploymentawsstatic-siteshell-scriptcdns3cloudfront

Repo hygiene

✓ all on main — nothing unmerged.