DEV Community

loading...

Few aws cli tricks

Ajeeb.K.P
Muslim, Husband, Programmer, Indian/Kerala. Speaks English, Malayalam. Always curious about technology, computing etc.
・1 min read

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

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

Discussion (1)

Collapse
waylonwalker profile image
Waylon Walker

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