Page updated Jan 16, 2024

Use transfer acceleration

When you use Transfer Acceleration, additional data transfer charges might apply. For more information about pricing, see Amazon S3 pricing.

You can enable Transfer Acceleration for fast and secure transfer of files over long distances between your end user device and the S3 bucket. You can override the storage resource for this configuration and then leverage the useAccelerateEndpoint parameter to use the accelerated S3 endpoint.

Override storage resource

Start by overriding your storage resources to enable Transfer Acceleration on your S3 bucket.

1$ amplify override storage
2✅ Successfully generated "override.ts" folder at <project>/amplify/backend/storage/accelerated-bucket
3✔ Do you want to edit override.ts file now? (Y/n) · yes
4Edit the file in your editor: <project>/amplify/backend/storage/accelerated-bucket/override.ts

In the generated override.ts file use the following CDK snippet to enable transfer acceleration.

1// amplify/backend/storage/accelerated-bucket/override.ts
2import { AmplifyS3ResourceTemplate } from '@aws-amplify/cli-extensibility-helper';
3
4export function override(resources: AmplifyS3ResourceTemplate) {
5 resources.s3Bucket.accelerateConfiguration = {
6 accelerationStatus: 'Enabled'
7 }
8}

Next, deploy this storage resource:

1amplify push

Use Transfer Acceleration on Storage Operations

You can use transfer acceleration by setting "useAccelerateEndpoint" to true in the corresponding pluginOptions for any of the following Storage APIs:

  • getUrl(key:options:)
  • downloadData(key:options:)
  • downloadFile(key:local:options:)
  • uploadData(key:data:options:)
  • uploadFile(key:local:options:)

For example, to upload a file using transfer acceleration:

1let uploadTask = Amplify.Storage.uploadFile(
2 key: aKey,
3 local: aLocalFile,
4 options: .init(
5 pluginOptions: [
6 "useAccelerateEndpoint": true
7 ]
8 )
9)
10
11let data = try await uploadTask.value