How do I use AWS CLI with Wasabi?
The AWS CLI (Command Line Interface) tool is certified for use with Wasabi. To use AWS CLI with Wasabi, follow the configuration tips below. Note that this article assumes that you have the awscli tool already installed. For more information on how to install it, refer to https://aws.amazon.com/cli/.
This example discusses the use of Wasabi's us-east-1 storage region. To use other Wasabi storage regions, use the appropriate Wasabi service URL, as described in Service URLs for Wasabi's Storage Regions.
Configuring AWS CLI Using the configure
Command
To access your wasabi buckets using the CLI, use the configure
command.
Typing $ aws configure
will bring up a series of prompts, calling for an access key and secret access key. Enter your Wasabi access key and your Wasabi secret key. For the region, type "us-east-1". Leave the last setting blank.
If you follow options 2 or 3 below, you will have to configure the [wasabi] profile after you create it. To do so, simply type
$ aws configure --profile wasabi
.
Using Wasabi With AWS CLI
There are three methods for using Wasabi with the CLI, ranked from requiring the least setup to the most.
Add the --endpoint-url
Subcommand After Every Command
Add the following after every command you execute in the CLI. Ensure you use the correct service URL for each region as listed in Service URLs for Wasabi's Storage Regions. The URL may be different from s3.wasabisys.com.
$ --endpoint-url=https://s3.wasabisys.com
Example:
To list buckets in the cli, type:
$ aws s3 ls --endpoint-url=https://s3.wasabisys.com
To make a new bucket in the eu-central-1 region, type:
$ aws s3 mb s3://newbucketnamehere --endpoint-url=https://s3.eu-central-1.wasabisys.com
To make a new bucket with object lock enabled in the us-central-1 region, type:
$ aws s3api create-bucket --bucket yournewbucketnamehere --object-lock-enabled-for-bucket --endpoint-url=https://s3.us-central-1.wasabisys.com
Example:
aws s3api create-bucket --bucket yournewbucketnamehere --object-lock-enabled-for-bucket --endpoint-url=https://s3.us-central-1.wasabisys.com
{
"Location": "/yournewbucketnamehere"
}
Using the awscli-plugin-endpoint
Plugin
The awscli-plugin-endpoint is a plugin that simplifies access to third-party S3 providers, like Wasabi. Using this plugin requires creating a new profile in addition to the default one.
Open the
config
file in the.aws
directory. Add a profile line at the end of the configuration file, as shown below.[profile wasabi]
Save the file.
Once you have a profile created, follow the instructions detailed on the plugin's git page.
You should then be able to use --profile wasabi
after each command instead of typing out the entire URL.
Example:
To list buckets in the cli, type:
$ aws s3 ls --profile wasabi
Using export AWS_PROFILE
with awscli-plugin-endpoint
Once you set up Option 2, you can make the AWS CLI default to the new profile at the start of your session. Follow the instructions below provided by AWS.
For Linux, macOS, or Unix:
$ export AWS_PROFILE=wasabi
For Windows:
> set AWS_PROFILE=wasabi
Setting the environment variable either changes the default profile until the end of your shell session or until you set the variable to a different value.
Example:
To list buckets in the cli, type:
$ aws s3 ls
Using AWS CLI for Cloud-to-Cloud Migration Scenarios
Install and configure AWS CLI using your AWS Access Key and Secret Key. For more information, refer to Get started with the AWS CLI.
Configure an additional AWS CLI profile for the Wasabi account using the Wasabi keys.
Transfer all files from the AWS bucket to a local directory by running the following command.
$ aws s3 cp s3:/// --recursive
Transfer all files from the local directory to the destination bucket at Wasabi.
$ aws s3 cp / s3:/// --recursive --profile wasabi
Uploading Large Files with AWS CLI
When uploading large files to Wasabi, multipart uploads are used to improve reliability, performance, and efficiency. By default, AWS CLI is configured to use 8 MB of chunk size and depending on the file size, the multipart could generate thousands of parts causing overhead in connections.
Wasabi recommends changing the default chunk size from 8 MB to 32 MB. To change this configuration, use the "aws configure set" command.
$ aws configure set default.s3.multipart_threshold 64MB
(This will configure the CLI to start using multipart only if the file is large than 64 MB)$ aws configure set default.s3.multipart_chunksize 32MB
(This will configure the CLI to use 32MB as the chunksize for each multipart)
Note:
Huge files: Use 64MB or 128 MB to reduce overhead and adjust it based on your needs.
Unstable networks: Use 16 MB to minimize retries.
Memory: When increasing the chunk size, you might need to adjust the amount of memory in your system.
Using AWS CLI v2 with Wasabi
AWS has implemented a new checksum algorithm, CRC64NVME, for Data Integrity at https://docs.aws.amazon.com/sdkref/latest/guide/feature-dataintegrity.html, which is causing an error for Wasabi customers when uploading to their buckets.
"The algorithm type you specified in x-amz-checksum- header is invalid."
The CRC64NVME is now the default checksum algorithm in the AWS CLI v2. Wasabi is aware of this issue and is working to implement this algorithm in our infrastructure.
In the meantime, if you want to use the AWS CLI v2 with Wasabi Services, you should force the checksum algorithm to CRC32 as specified below.
$ aws s3 cp <FILENAME> s3://<YOURBUCKETNAME> --endpoint-url https://s3.<WASABI-REGION>.wasabisys.com --checksum-algorithm=CRC32
For PowerShell and SDKs please refer to the links below.
PowerShell - https://docs.aws.amazon.com/powershell/latest/reference/
AWS SDK - https://aws.amazon.com/developer/tools/
Additional Information
For additional information regarding AWS CLI, refer to the following resources.