Data ownership with Contentful

Contentful provides 99.96 to 99.99 availability depending on your enterprise SLA. This is sufficient in most cases, but sometimes you need even more reliability. Enterprises that store critical data in Contentful may need to satisfy legal or compliance requirements associated with data ownership and business continuity. Regulated and public enterprises might need to have backup protection in the unlikely event that Contentful ceases to operate in the future.

Contentful and AWS S3 offer a reliable, secure and out-of-the-box integration that solves these demands. It backs up data on your own infrastructure and allows you to maintain an audit log. You could also build a custom HA/DR/BPC procedure with Contentful.

Setting up AWS

Integrating AWS and Contentful begins by setting up an S3 bucket on AWS.  Below are screenshots that show how an S3 bucket is created via the AWS console:

Integrating AWS and Contentful begins by setting up an S3 bucket on AWS

You will need to enable versioning, as seen below. This stores multiple versions of the same file as one:

You will need to enable versioning, as seen below.

Use an existing user with the right permissions, or generate a new Access ID and Access Key that can be used from Contentful to write in this folder. The latter is the better option.

That’s all that is required from AWS. The remaining configuration can be done from the  Contentful web app. You need to be an admin or an owner of the space that you’re using to do so.

Using Contentful

Create a new webhook within Contentful using the AWS S3 template. 

Create a new webhook within Contentful using the AWS S3 template.

Enter the region and the name of the bucket, along with the access credentials. 

When an entry is created or updated, a JSON file is stored in this S3 bucket with all the info of the entry. The JSON file is versioned — you always see the latest version. If you want to publish content and aren’t concerned with draft content, then update the events when the webhook is triggered under the webhook settings. 

This covers most of the use cases:

  1. Backup of Contentful data in your AWS S3.

    1. You own your data, it is in your cloud.

    2. You’re ensured compliance and data availability in the unlikely event that Contentful does not exist in the future. 

  2. Create an audit log, because the data contains user information for each entry. Notice each JSON is associated with the user ID who made the change.

We still need to do one more thing to satisfy HA, DR and BCP requirements. If you are accessing Contentful directly from a client:

  1. Create a lambda or similar function that can be called from the client.

  2. In the lambda, make the Contentful call.

  3. If this fails, make the call to the S3 bucket to get the corresponding JSON.

  4. Massage the JSON from the S3 and remove unwanted elements. 

  5. Return it to the client. 

If you have a service that merges Contentful content and some form of React/Mustache templates, update this service to call the S3 bucket (similar to above) if Contentful is down.

Now,  even if Contentful is down, your digital experience will still function with the latest published data from the S3 bucket. 

Reliable integrations solve complex requirements

This simple, out-of-the-box integration between Contentful and AWS S3 is reliable and solves complex enterprise requirements. It demonstrates just how flexible and reliable SaaS- and API-based integrations are.

You can read more solutions to complex situations written by the Contentful team in our eBook Customizing Contentful: A developer’s guide.

About the author

Don't miss the latest

Get updates in your inbox
A monthly newsletter to help you build better digital experiences with Contentful.
add-circle remove style-two-pin-marker subtract-circle