Gatsby Cloud Docs

Getting started with Gatsby Cloud and S3

Table of Contents

Gatsby Cloud integrates with Amazon S3, which is a storage service that can be used for hosting a Gatsby site so you can build and deploy seamlessly.

Prerequisites

With a site on Gatsby Cloud and an available bucket on Amazon S3, you can set up your site to publish newly built files to your S3 bucket.

You can set up Gatsby Cloud to autoprovision a new Gatsby site if you don’t have one. Alternatively, you can add an existing site to Gatsby Cloud by selecting that GitHub repository during set up.

Setting Up the Hosting Integration

Once your site is available inside Gatsby Cloud you can “view details” and navigate to the “Site Settings” tab.

Inside Site Settings there is an “Integrations” link. Select this menu item and scroll down to the section titled “Hosting Integrations”.

This is where you’ll see the AWS S3 logo. Click the “Connect” button to the right of that logo and you’ll be prompted to add some information:

  • Access Key ID
  • Secret Access Key
  • Bucket Name
  • File Key Prefix (Optional)

To get the Access Key ID and Secret Access Key, you’ll have to create a new set of keys from the AWS IAM service. IAM can allow programmatic access to different resources, you’ll need to create a key with access to S3. You can attach an existing AWS policy like “AmazonS3FullAccess” so that Gatsby Cloud can add files to S3 for you.

Once you hit save, builds will automatically be deployed to the bucket with the bucket name you provided.

Configuring Bucket Settings

Refer to the AWS docs on using a bucket for static hosting for more information on configuring specific settings for your bucket in the AWS Console.

Some options you might need to update are enabling “Static website hosting” in the “Properties” tab of your bucket. You will also need to configure permissions to make files inside the bucket publicly accessible.

Finishing Up

And that’s it! Your site is now set up to build and deploy. Gatsby Cloud will handle everything for you. You can make edits to which bucket is being deployed to by going back to the “Hosting Integrations” section.

Note that you can only have one hosting integration. If you choose to configure another provider, that will override your existing Amazon S3 integration.

FAQ

Can I put a CDN in front of my S3 bucket?

Yes, you can configure Amazon Cloudfront to serve the files in your S3 bucket, or connect a bucket to another preferred CDN.