AWS CLI for Fastly Object Storage

The Amazon Web Services (AWS) CLI can be configured to use Fastly Object Storage as an S3 backend.

Prerequisites

  1. Install AWS CLI v2. Refer to the AWS documentation for more information.
  2. If you haven't already, purchase Fastly Object Storage.
  3. Create an Access Key and Secret Key for Fastly Object Storage.

Configure AWS CLI for Fastly Object Storage

  1. Create or update the AWS CLI config file for your platform.

    1. Unix-based
    2. Windows-based
    ~/.aws/config

    The config file contains AWS CLI Profiles.

    Each Fastly Object Storage region should be added as an individual profile for AWS CLI. These profiles can be named whatever you would like, but below we include the Fastly Object Storage region in the profile name to make it clear which region is associated with which profile.

    The config file for your system should have the following added to it:

    [profile fastly-us-east]
    region = us-east
    endpoint_url = https://us-east.object.fastlystorage.app
    request_checksum_calculation = when_required
    [profile fastly-us-west]
    region = us-west
    endpoint_url = https://us-west.object.fastlystorage.app
    request_checksum_calculation = when_required
    [profile fastly-eu-central]
    region = eu-central
    endpoint_url = https://eu-central.object.fastlystorage.app
    request_checksum_calculation = when_required
  2. Create or update the credentials file for your platform

    1. Unix-based
    2. Windows-based
    ~/.aws/credentials

    The credentials file contains the Fastly Object Storage access credentials associated with a like-named profile in the config file.

    WARNING

    The following steps will store your Fastly Object Storage credentials in plaintext in a file on disk. This is not recommended in a production environment.

    For production environments, AWS CLI supports other methods of providing credentials such as through environment variables or from external tooling such as a password manager.

    To do this for the example profiles above, we must edit the credentials file and add the following:

    [fastly-us-east]
    aws_access_key_id = <YOUR FASTLY OBJECT STORAGE ACCESS KEY ID HERE>
    aws_secret_access_key = <YOUR FASTLY OBJECT STORAGE SECRET KEY HERE>
    [fastly-us-west]
    aws_access_key_id = <YOUR FASTLY OBJECT STORAGE ACCESS KEY ID HERE>
    aws_secret_access_key = <YOUR FASTLY OBJECT STORAGE SECRET KEY HERE>
    [fastly-eu-central]
    aws_access_key_id = <YOUR FASTLY OBJECT STORAGE ACCESS KEY ID HERE>
    aws_secret_access_key = <YOUR FASTLY OBJECT STORAGE SECRET KEY HERE>

The AWS CLI is now ready to be used with Fastly Object Storage.

Basic AWS CLI Commands

The following provides a sample of common commands to interact with Fastly Object Storage via the AWS CLI.

TIP

Note the use of the --profile flag to choose which Fastly Object Storage region to perform commands against.

Create a bucket named photos in the us-east region:

$ aws s3 mb s3://photos --profile fastly-us-east

Upload a local file called sunset.png to the photos bucket:

$ aws s3 cp sunset.png s3://photos/sunset.png --profile fastly-us-east

Download the object named sunset.png from the photos bucket to a local file called sunset-copy.png:

$ aws s3 cp s3://photos/sunset.png sunset-copy.png --profile fastly-us-east

Delete an object named sunset.png from the photos bucket:

$ aws s3 rm s3://photos/sunset.png --profile fastly-us-east

Delete the photos bucket (the bucket must be empty before being deleted):

$ aws s3 rb s3://photos --profile fastly-us-east

Refer to the AWS CLI Documentation for more commands. Refer to Fastly Object Storage's documentation for additional limitations and considerations.

Was this guide helpful?

Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.