Skip to main content

How to deploy to AWS S3 Buckets

Introduction#

Uniform can deploy content from Sitecore to S3 buckets. The following functionality is available:

  1. Publish pages to S3 buckets
  2. Publish media files to S3 buckets
  3. Purge cache on CloudFront distribution
tip

You can use these features independently. For example, you can just publish media files to an S3 bucket without having to publish pages there, too.

Pre-requisites#

  1. You have completed the Getting Started section, so your site is ready to be deployed to static storage.
  2. Uniform for Sitecore starter kit (for Deploy).
  3. AWS account with the ability to create S3 buckets and CloudFront distributions.
  4. AWS account with the ability to create access keys.

AWS setup#

Uniform does not have any special requirements for the AWS configuration. The configuration that is needed is typical of what you would expect when you want to use CloudFront to serve files from an S3 bucket.

  1. In AWS, create a new S3 bucket, with public access enabled with read permissions.

    info

    Note the AWS region and bucket name. You will need these values to configure Sitecore to be able to deploy files to the bucket.

  2. Create an access key that has read/write permissions on the S3 bucket.

    info

    Note the access key and secret key values. You will need these values to configure Sitecore to be able to deploy files to the bucket.

  3. Create a new CloudFront distribution, with the origin domain set to the S3 bucket.

    info

    Note the distribution ID. You will need this value to configure Sitecore to be able to send cache purge commands to the distribution.

  4. Create an access key that has cache purge permissions on the distribution.

    info

    Note the access key and secret key values. You will need these values to configure Sitecore to be able to send cache purge commands to the distribution.

Sitecore setup#

tip

Not all of the configuration described below is required. For example, if you are not deploying a static site, you do not need to complete the section on how to deploy pages to an S3 bucket.

Initial setup#

The following configuration is required for all of the functionality below.

  1. In Sitecore, open Content Editor.

  2. Navigate to your site's SiteConfiguration item under sitecore > system > Uniform > SiteConfigurations.

    info

    If an item for your site does not exist, create an item using Site Configuration.

  3. If a Configuration item is not the child of the SiteConfiguration item, create an item using Configure Site.

    info

    If you create this item, be sure to set the value for the field Inherits to the name of your Sitecore site.

Deploy pages to S3 bucket (optional)#

If you are using Uniform Deploy to generate a static site from a Sitecore site, you need a place to store the static files. You can configure Uniform to publish the files to an S3 bucket.

  1. Navigate to your site's SiteConfiguration item under sitecore > system > Uniform > SiteConfigurations.

  2. Select the item Configuration.

  3. Create an item using Configure: AWS for Pages.

  4. Set the field values using the details you noted when configuring AWS.

Deploy media files to S3 bucket (optional)#

There are multiple cases where you might want to publish media files to an S3 bucket. If you are using Uniform Deploy to generate a static site, media files can be stored in an S3 bucket. If you are using Uniform Platform, you can publish media files to an S3 bucket in order to eliminate the need for Sitecore CD instances.

  1. Navigate to your site's SiteConfiguration item under sitecore > system > Uniform > SiteConfigurations.

  2. Select the item Configuration.

  3. Create an item using Configure: AWS for Media.

  4. Set the field values using the details you noted when configuring AWS.

tip

Sitecore is responsible for generating URLs for media files. You should check if the setting Media.MediaLinkServerUrl is configured on your Sitecore instance. If it is set, make sure it is not set to a value that will prevent the links from being generated in a way that is compatible with the URLs on CloudFront.

Purge cache for CloudFront distribution (optional)#

If you are storing any files in an S3 bucket and using CloudFront to serve the files, you might want to be able to purge the CloudFront when you deploy files to the S3 bucket.

  1. Navigate to your site's SiteConfiguration item under sitecore > system > Uniform > SiteConfigurations.

  2. Select the item Configuration.

  3. Create an item using Configure: CloudFront Purge Service.

  4. Set the field values using the details you noted when configuring AWS.

    info

    If you specified a region value in your CloudFront configuration, you should use the same value here.