Upload to MTN Object Storage (MOS) using AWS CLI on MTN Cloud
Overview
This guide shows how to upload files or data to a bucket in MTN Object Storage (MOS) using the AWS CLI. It covers creating a CLI profile with your MOS keys, setting the AWS checksum options, and running the upload command.
Why it matters:
- Command-Line Uploads: Push files to your bucket from a terminal, which suits scripted and repeated transfers.
- Reusable Profile: Your MOS Access Key and Secret Key are stored once in a named profile that every later command can use.
- Works with Existing Buckets: Upload to any bucket already created in your MOS environment.
Prerequisites
Before you begin, ensure you have:
- An active MTN Cloud account.
- MTN Object Storage (MOS): at least one existing bucket within your storage environment.
- Your MOS Access Key and Secret Key.
- Your MOS endpoint URL.
- The AWS CLI installed on the machine you will upload from.
Tip: If you do not see the required features and resources, contact your tenancy administrator (Customer Admin User) or support. A refresh of the portal page may also resolve this.
The Right Sequence
To upload your files to MTN Object Storage using the AWS CLI, follow this sequence:
- ●Create a Profile: Store your MOS Access Key and Secret Key under a named profile.
- ●Set the AWS Checksum Options: Configure the AWS CLI to calculate request and response checksums only when required.
- ●Upload the File: Run the copy command with your bucket, endpoint URL and profile.
Phase 1 — Create a Profile
Purpose: Save your MOS credentials in a named AWS CLI profile so that later commands can authenticate to MTN Object Storage.
- Run the following command in your terminal, replacing <profile-name> with a name of your choice:
aws configure --profile <profile-name>
- When prompted, enter your MTN Object Storage (MOS) Access Key and Secret Key to complete the configuration.
Phase 2 — Set the AWS Checksum Options
Purpose: Set the AWS CLI to calculate request and response checksums only when an operation requires them.
Run the following commands in your terminal (Windows Command Prompt):
set AWS_REQUEST_CHECKSUM_CALCULATION=WHEN_REQUIRED set AWS_RESPONSE_CHECKSUM_CALCULATION=WHEN_REQUIRED
Note: On Linux or macOS, use export instead of set, for example: export AWS_REQUEST_CHECKSUM_CALCULATION=WHEN_REQUIRED. These variables apply to the current terminal session only, so set them again whenever you open a new terminal.
Phase 3 — Upload the File
Purpose: Copy a local file to your MOS bucket.
- Run the following command in your terminal, replacing the placeholders with your own values:
aws s3 cp <local-file-path> s3://<bucket-name>/ --endpoint-url <your-endpoint-url> --profile <profile-name>
Placeholder Replace with <local-file-path> The full path to the file on your machine <bucket-name> The name of the existing MOS bucket to upload to <your-endpoint-url> Your MOS endpoint URL <profile-name> The profile name you created in Phase 1 - When the command finishes, the AWS CLI reports the upload. To confirm that the file is in the bucket, list its contents:
aws s3 ls s3://<bucket-name>/ --endpoint-url <your-endpoint-url> --profile <profile-name>
Final Notes
- Keep Your Keys Secure: Your Access Key and Secret Key give full access to your buckets. Do not share them or store them in documents or scripts.
- Reuse Your Profile: You can reuse the same profile for later uploads, so Phase 1 only needs to be done once per machine.
- Checksum Options: Set the checksum variables in Phase 2 again in each new terminal session before you upload.