DEV Community

Ajeeb.K.P
Ajeeb.K.P

Posted on

Few aws cli tricks

Introduction

These are excitements of a newcomer to the aws-cli ecosystem.

In summary

  • Using aws cli without installing
  • AWS Profiles
  • aws-cli history

Trick: Using aws cli without installing

I was following https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html for installing version 2 of aws cli.

Three commands are needed to install it. If you don't want to install (like me), don't do last step.

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
Enter fullscreen mode Exit fullscreen mode

Instead create a bash alias like this, which pointing ./aws/dist/aws file
alias aws=/<path/to/aws-extracted-folder>/dist/aws

If you want use it all the time (which you probably want), just add above alias to your ~/.bashrc or ~/.bash_aliases (Bash aliases are loaded in most distros automatically, if not you might load it with source ~/.bash_aliases).

Trick: AWS Profiles

This is a useful feature if you using multiple accounts of aws.
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

In short, create a profile by following command

aws configure --profile theProfileName

After passing proper credentials, you can use it with almost all commands. For example,

aws s3 ls --profile theProfileName

Actually, these values are stored in ~/.aws/credentials (Linux & Mac) or %USERPROFILE%\.aws\credentials (Windows). I guess, you can edit and change if you want (I didn't test my self).

Trick: History

Use following command once to enable
aws configure set cli_history enabled
Now onwards use following commands to see
aws history list

Top comments (1)

Collapse
 
waylonwalker profile image
Waylon Walker

I am definitely checking these out. Profile and history look super useful