awslabs / awslabs/aws-shell

[Feature Request] Ability to define command aliases per-profiles.

Open
#234 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.3k
Forks
780
PR merge metrics
No merged PRs in 30d

Description

Hello, i'm trying it out the aws-shell in my environment but i found that the Os shell commands ( !.. )
are not honoring my environment aliases. Bash or ZSH defined aliases for example.

Before aws-shell, years ago, I've writed myself a simple custom bash/zsh profile applied to a common centos-vm witch was a simple wrapper around aws-cli, enabling to switch between accounts ( export all the variables needed for awscli and a bunch of custom defined ones enabling some functionalities binded to the profile one's connecting to ) .. since now ...my team is using this simple approach to administer aws from the cli --> ssh@"awsconsole vm" with own AD username ... the profile script asks on login where to connect on aws-side, reading a list of pre-configured aws-profiles --> user inputs VPCNAME, role, IAM Creds, region etc... --> the wrapper exports the Environment Variables needed... and presents the shell ( the OS bash or zsh ) with aws-cli enabled and ready to work. Also swith between profiles is possible.

So long story short... i really would like to use aws-shell and get rid of my old solution... but there is a missing feature, really really usefull in my opinion ... the ability to specify custom commands per-aws profiles. ( aliases ...)

**THE PROPOSAL**

Why not use the dot command ".alias" --> opens the editor similar to .editor .. and be able to specify :
```
ALIASNAME="shell command pipeline"
ALIASNAME="Another cool command"
```
This should be saved ( maybe ) inside **~/.aws/shell/aliases/** with the format _CURRENTPROFILE.aliases_

This way also would be an OS agnostic configuration..

The expected behaviour should be that when "aws-shell --profile WHATEVER" opens
it loads the aliases corresponding to the profile you are connecting to, and when using the !COMMAND feature it resolves the defined correspondings.
If a command is present, with the same name, in Os shell and alias definition.. the alias definited INSIDE aws-shell **should take precedence**... ( Override .. just like it is in plain bash/zsh )

So for example... if i define for profile "COMPANY01" the aliases ( Just using the .**alias** dot-command inside the aws-shell ):
```
ssh="ssh -Y -i /company01-aws-keys/$(echo whoami).pem "
```

inside the aws-shell:
```
!ssh centos@instance-name --> works as expected and also the configuration is portable from the aws-shell prospective.
```

Just a simple example... the ability to extend the aws-shell with custom PER-Profile aliases/overrides/custom-commands would be awsome.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the !COMMAND entry point and how aws-shell --profile selects a profile; compare that flow with the existing .editor dot-command. The proposed .alias behavior should load aliases from ~/.aws/shell/aliases/ for the active profile, resolve them for !COMMAND, and give them precedence over OS-shell aliases.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, bash, python, zsh
Domain
cli, cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.