All Projects → jonelantha → gatsby-s3-action

jonelantha / gatsby-s3-action

Licence: MIT license
Deploy a Gatsby Project to an AWS S3 bucket (optional Cloudfront support)

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to gatsby-s3-action

Serverless Sharp
Serverless image optimizer for S3, Lambda, and Cloudfront
Stars: ✭ 102 (+155%)
Mutual labels:  s3-bucket, cloudfront
simply-static-deploy
WordPress plugin to deploy static sites easily to an AWS S3 bucket.
Stars: ✭ 48 (+20%)
Mutual labels:  s3-bucket, cloudfront
Gatsby Plugin S3
Deploy your gatsby site to a S3 bucket.
Stars: ✭ 186 (+365%)
Mutual labels:  s3-bucket, cloudfront
React Apig Lambda
Render React.js on-demand with CDN caching
Stars: ✭ 93 (+132.5%)
Mutual labels:  s3-bucket, cloudfront
Git S3 Push
Deploy your git repo to an S3 bucket
Stars: ✭ 182 (+355%)
Mutual labels:  s3-bucket
S3fs
S3 FileSystem (fs.FS) implementation
Stars: ✭ 93 (+132.5%)
Mutual labels:  s3-bucket
Aws S3
S3Client - A Javascript Library for AWS S3 File Upload
Stars: ✭ 79 (+97.5%)
Mutual labels:  s3-bucket
Aws Cli Docker
Docker container with the AWS CLI
Stars: ✭ 62 (+55%)
Mutual labels:  s3-bucket
smockin
Dynamic API, S3 & Mail mocking for web, mobile & microservice development.
Stars: ✭ 74 (+85%)
Mutual labels:  s3-bucket
Terraform Aws Tfstate Backend
Terraform module that provision an S3 bucket to store the `terraform.tfstate` file and a DynamoDB table to lock the state file to prevent concurrent modifications and state corruption.
Stars: ✭ 229 (+472.5%)
Mutual labels:  s3-bucket
Festin
FestIn - S3 Bucket Weakness Discovery
Stars: ✭ 161 (+302.5%)
Mutual labels:  s3-bucket
Aws Scanner
Scans a list of websites for Cloudfront or S3 Buckets
Stars: ✭ 93 (+132.5%)
Mutual labels:  s3-bucket
0x4447 product s3 email
📫 A serverless email server on AWS using S3 and SES
Stars: ✭ 2,905 (+7162.5%)
Mutual labels:  s3-bucket
Google Sheet S3
Google Apps Script that publishes a Google Sheet to Amazon S3 as a JSON file. Auto-updates on edit & maintains data types. Creates an array of objects keyed by column header.
Stars: ✭ 81 (+102.5%)
Mutual labels:  s3-bucket
nextjs-ssr-isr-cdk-aws
🦄 ‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎Next.js webapp using Server Side Rendering (SSR) and Incremental Static Regeneration (ISR) deployed with Serverless Nextjs CDK construct on AWS using CloudFront and Lambda@Edge
Stars: ✭ 78 (+95%)
Mutual labels:  cloudfront
Aws Lambda Swift Sprinter
AWS Lambda Custom Runtime for Swift with swift-nio 2.0 support
Stars: ✭ 70 (+75%)
Mutual labels:  s3-bucket
Minfs
A network filesystem client to connect to Minio and Amazon S3 compatible cloud storage servers
Stars: ✭ 222 (+455%)
Mutual labels:  s3-bucket
Sbt S3 Resolver
☁️Amazon S3-based resolver for sbt
Stars: ✭ 112 (+180%)
Mutual labels:  s3-bucket
Cloudexplorer
Cloud Explorer
Stars: ✭ 170 (+325%)
Mutual labels:  s3-bucket
s3redirect
Turn S3 into a URL redirect website using lambda and NO database!
Stars: ✭ 31 (-22.5%)
Mutual labels:  cloudfront

gatsby-s3-action

Deploy a Gatsby site to an AWS S3 bucket and optionally invalidate a CloudFront distribution

  • Supports Gatsby v5, v4, v3 & v2 static (SSG) sites 🚀
  • Copies a Gatsby site to the root of an S3 bucket (uses sync --delete so old files in the bucket will be removed - can be disabled by using sync-delete: false, see Parameters Reference).
  • Sets cache headers as defined by the rules described in the Gatsby documentation.
  • Fast - uses AWS Cli commands for mass file operations which only create/modify files as needed.
  • Suitable for hosting with or without CloudFront. If a CloudFront distribution is specified then it will be invalidated after deployment.

Please read the notes on the AWS Setup below.

For a full step by step guide for setting up from scratch please take a look at GitHub Actions powered Gatsby AWS how-to guide.

QUICK RECIPE: S3 Static Hosting, no CloudFront

name: Deploy

on:
  push:
    branches:
      - main            # could be 'master' on older repos
jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18
      - name: Build
        run: |
          npm ci
          npm run build
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1-node16
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: eu-west-2
      - name: Deploy
        uses: jonelantha/gatsby-s3-action@v2
        with:
          dest-s3-bucket: your_bucket
  • AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY are obtained from the AWS console, see AWS IAM Secrets below.
  • your_bucket should be changed to the name of your bucket
  • See Parameters Reference below for the full list of parameters

QUICK RECIPE: With CloudFront

Add the cloudfront-id-to-invalidate parameter to specify the ID of a distribution to be invalidated after deployment.

     - name: Deploy
        uses: jonelantha/gatsby-s3-action@v2
        with:
          dest-s3-bucket: your_bucket
          cloudfront-id-to-invalidate: CLOUDFRONTID

QUICK RECIPE: Deploy to a sub-directory on S3

Add the dest-s3-path parameter to specify a sub-directory to copy to in your bucket.

     - name: Deploy
        uses: jonelantha/gatsby-s3-action@v2
        with:
          dest-s3-bucket: your_bucket
          dest-s3-path: blog/files

QUICK RECIPE: With a non-standard Gatsby build directory (default is ./public/):

Gatsby builds to ./public by default. If you've changed the build directory to something else then use public-source-path to specify that directory:

     - name: Deploy
        uses: jonelantha/gatsby-s3-action@v2
        with:
          dest-s3-bucket: your_bucket
          public-source-path: ./build/

AWS Setup

AWS IAM Secrets

You'll need to setup an AWS IAM user with Programmatic Access and then configure the AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY in the Settings/Secrets area of the repo. Ideally you should follow Amazon IAM best practices and grant least privileges to the user:

  • s3:ListBucket on arn:aws:s3:::your_bucket
  • s3:PutObject, s3:GetObject, s3:DeleteObject on arn:aws:s3:::your_bucket/*
  • (only if you're using CloudFront) cloudfront:CreateInvalidation on arn:aws:cloudfront::YOURACCOUNT_ID:distribution/YOURCLOUDFRONTID

For a complete walkthrough of setting up the user, please see the first section of the associated Setting up Github Actions for Gatsby guide

S3

  • With CloudFront:
    • The S3 bucket does not need to be set for public access but the CloudFront distribution should have access to your bucket, see the CloudFront section below.
  • Without CloudFront, S3 Static Website hosting only:
    • Use these S3 Static Website Hosting settings:
      • Index Document: index.html
      • Error Document: 404.html

CloudFront

Your CloudFront distribution will need read access to your S3 bucket. More information in the AWS Gatsby S3 CloudFront guide but in short this is easy to configure when you create your CloudFront distribution, just make sure you use the following settings on the Create Distribution screen:

  • Origin Access Identity: Create New Identity
  • Grant Read Permissions on Bucket: Yes Update Bucket Policy

Also, you'll need to setup a CloudFront Function on the CloudFront distribution to properly handle serving up index.html files. More information in the Gatsby CloudFront Function guide. Alternatively if you'd prefer to set up index handling using a lambda@edge function, please see the Gatsby CloudFront Lambda guide

Redirects

If you plan to use Gatsby redirects you'll need to use a Gatsby redirect plugin such as one of the following:

Parameters Reference

Argument Status Description
dest-s3-bucket Required The destination S3 Bucket
dest-s3-path Optional The destination S3 Path (defaults to root)
cloudfront-id-to-invalidate Optional The ID of the CloudFront distribution to invalidate.
cloudfront-path-to-invalidate Optional The path to invalidate on the CloudFront distribution. See the CloudFront Invalidation guide for information on the format (default: /*)
public-source-path Optional The path to your gatsby ./public directory. Default: is ./public/
sync-delete Optional Boolean: delete files on S3 not in the latest Gatsby build (defaults to 'true')
browser-cache-duration Optional The cache duration (in seconds) to instruct browsers to cache files for. This is only for files which should be cached as per Gatsby caching recommendations. Default is 31536000 (1 year)
cdn-cache-duration Optional The cache duration (in seconds) to instruct a CDN (if there is one) to cache files for. If on a development environment and you want to avoid issuing CloudFront invalidations you could set this to 0. Default is 31536000 (1 year)
debug Optional Boolean: enable debug logging (defaults to 'false')
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].