On-Demand Migration for Fastly Object Storage

On-Demand Migration for Fastly Object Storage lets you transfer your data into Fastly Object Storage. This method takes a stateless approach that helps you only migrate your required working set of data to reduce egress charges from your source provider. Here's how it works:

  1. A client requests an object from your Fastly Object Storage bucket. If the object is present in the bucket, it's returned to the user.
  2. If the object is not yet present in the bucket, the Object Storage service reads the location using the URL provided in the fastly-object-storage-source-url header.
  3. The object is fetched from the provided URL and simultaneously served to the requesting user and asynchronously migrated into your Object Storage bucket.

HINT: Because each object is migrated on the first request, implementing Fastly Bot Management can help prevent bots from scraping assets and causing them to migrate before they're actually needed.

Before you begin

Make sure you review the prerequisites for using Fastly Object Storage.

Limitations and considerations

Note the following limitations and considerations when using On-Demand Migration for Fastly Object Storage:

  • The fastly-object-storage-source-url header must be included in the set of signed headers when generating the AWS Sigv4 signature.
  • On-Demand Migration for Fastly Object Storage does not support objects greater than 250 MB. If an object greater than 250 MB is requested, the response will show that the object is available in the source, but the object won't be copied to the Fastly bucket.
  • The server at provided source URL must respond with an HTTP 200 OK or HTTP 206 Partial Content status code for a migration to occur. Additionally, in the case of a range request to Fastly Object Storage when using On-Demand Migration, the entire object will be migrated into Fastly Object Storage and only the requested range will be returned to the caller.

Using On-Demand Migration

To use On-Demand Migration for Fastly Object Storage, you must set a single header, fastly-object-storage-source-url, on a standard GetObject request.

First, set the fastly-object-storage-source-url header to the URL of the object you want to migrate, typically a non-Fastly storage provider like AWS S3. If the object is in a private S3 bucket, use a pre-signed URL to grant temporary, time-limited access to specific objects within an S3 bucket without requiring the recipient to have AWS credentials or permissions.

IMPORTANT: The fastly-object-storage-source-url header must be included in the set of signed headers when generating the AWS Sigv4 signature.

Then, create a GetObject request to https://fos-region.object.fastlystorage.app/my-fos-bucket/object-key where:

  • fos-region.object.fastlystorage.app is the regional Object Storage endpoint where you want to send the request.
  • my-fos-bucket is the name of your Object Storage bucket.
  • object-key is the name of the object in your Object Storage bucket.

Validating migration

To check whether a specific object has been migrated into Fastly Object Storage, send a HeadObject request to the same region, bucket, and object key that was used for the On-Demand Migration GetObject request. If the object was successfully migrated, an HTTP 200 OK response will be returned indicating that the object exists in the Fastly Object Storage bucket.

Error handling

On-Demand Migration reports errors through both an XML response body and a fastly-object-storage-migration-error header, which contains a description of the error that occurred. For example, if the source server responds with a 503 Service Unavailable status code, the fastly-object-storage-migration-error header will report OnDemandMigrationSourceStatus 503.