Publish a site to AWS

Publish a site to AWS Amplify, deploying a snapshot of your content together with the site in snapshot-file mode.

Step 1: Generate a snapshot of content

Consider a snapshot as a directory of static content previously pulled from your content sources, which does not update itself.

> yarn gen:snapshot

The snapshot is written to snapshots/latest.

Step 2: Create a Github repository

Commit the snapshot together with the site.

> git init
> git remote add origin git@github.com:username/my-sample-site.git
> git add .
> git commit -m "initial commit"
> git push origin main

Step 3: Setup AWS

Switch to the AWS Amplify console and deploy your app as a SSR application by following the AWS docs.

Step 4: Configure your AWS app

Add the environment vars to the hosted app via your console

MOSAIC_MODE="snapshot-file"
MOSAIC_SNAPSHOT_DIR="snapshots/latest"

Add the following build settings

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
        - env | grep -e MOSAIC >> .env.production
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Ensure the Node is set to 16

Step 5: Publish content updates

To publish new content, generate a new snapshot, then commit and push it. Amplify rebuilds the site with the new snapshot.

> yarn gen:snapshot
> git add snapshots
> git commit -m "update snapshot"
> git push origin main
Mosaic BETA

Coming soon