Simplifying AWS S3 CLI Usage with Aliases

The Storage Made Easy File Fabric provides an S3 compatible API into any on-premises or on-cloud storage whether the storage provider supports the S3 protocol or not.

The AWS CLI is one of the best opensource tools for working with S3 compatible storage.  When working with storage providers other than Amazon, the commands can get lengthy to type.

Simply access with Aliases in Mac, Windows, and Linux

Working with AWS CLI and Storage Made Easy can involve alot of typing.  Aliases minimize the typing needed.  Turn the following:

aws --endpoint=https://s3.storagemadeeasy.com --profile=SME s3 ls

Into:

fileFabric s3 ls

Linux Aliases

Linux users have a hidden file called .bashrc which contains environmental settings.  Adding an alias to .bashrc will allow for tab autocompletion for the aws cli command.

Once aws cli is configured and working add the endpoint and profile settings to ~/.bashrc with your favorite editor.  There should already be an alias section.

The following example uses “fileFabric” as the alias for accessing the SME profile and endpoint.

alias fileFabric='aws --endpoint=https://s3.storagemadeeasy.com --profile=SME'

Once added, either log out or use the following command to reload the environment:

source ~/.bashrc

Now give it a try:

fileFabric s3 ls s3://SME

Mac OS X Aliases

Mac users can add aliases to a file called .bash_profile.

First create .bash_profile

touch ~/.bash_profile

Now add the following example which uses “fileFabric” as the alias for accessing the SME profile and endpoint.

alias fileFabric='aws --endpoint=https://s3.storagemadeeasy.com --profile=SME'

Once added, either log out or use the following command to reload the environment:

source ~/.bash_profile

Now give it a try:

fileFabric s3 ls s3://SME

Windows Aliases

Windows can also use aliases.  To use the alias “fileFabric” to access the US SaaS server do the following:

Create a text file env.cmd in the user’s Documents folder. Add the following to it:

@echo off
doskey fileFabric=aws --endpoint=https://s3.storagemadeeasy.com --profile=SME $*

Next open Regedit and add the following Key

HKEY_CURRENT_USER\Software\Microsoft\Command Processor
Name: AutoRun
Type: REG_SZ   (String Value)
Data: %USERPROFILE%\Documents\env.cmd

Now open the command prompt and give it a try:

fileFabric s3 ls s3://SME

Conclusion

Aliases are great for saving typing when using AWS CLI with the Storage Made Easy File Fabric or other non-Amazon S3 compatible Storage.

Print Friendly, PDF & Email
Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather
The following two tabs change content below.

Douglas Soltesz

Director Product Solutions at Storage Made Easy
Doug's focus is in Object and Cloud Storage APIs, Data Governance, Virtualization, and Containerization.

Latest posts by Douglas Soltesz (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *