Skip to main content

configure AWS responsibly using profile names.

Project description

caws

configure AWS responsibly using profile names and environment vars.

rather than changing your AWS SDK credentials with aws configure, AWS suggests
setting the ENV var AWS_DEFAULT_PROFILE to a [profile] in your ~/.aws/credentials.
when set, this ENV var will over-ride the profile set with aws configure.

caws will write to an rc file setting AWS_DEFAULT_PROFILE to the given profile name.
if you do not have the rc file caws will create it for you.

you'll need to add . .cawsrc to your RC file (using bash: .bashrc or .bash_profile)

add new profiles using $ aws configure --profile newname

one benefit of using AWS_DEFAULT_PROFILE method instead of aws configure is the
ability to add which AWS profile you're currently using to your command prompt.

dependencies

python3
aws cli

usage

change AWS_DEFAULT_PROFILE to profilename
$ caws profilename

change AWS_DEFAULT_PROFILE to profilename and also update ~/.aws/credentials and ~/.aws/config
$ caws profilename --withcreds

show help and exit
$ caws -h

example bash usage

because python cannot source files on the parent process, caws has the unfortunate inability to update the ENV var it is updating.
therefore, a thin bash helper function can be used to run caws in the background:

kaws() {
 eval "caws $1 > /dev/null"
 . ~/.cawsrc  
}

example PS1 with colored path parts!

function color_path() {
    ROYGBIV=('\e[31m' '\e[38;5;208m' '\e[93m' '\e[92m' '\e[36m' '\e[94m' '\e[95m' '\e[97m' '\e[93m' '\e[38;5;208m' '\e[91m' '\e[95m' '\e[96m' '\e[34m' '\e[92m')
    explode_path=$(pwd)
    exploded=$(echo $explode_path | tr "/" "\n")
    final=""
    sep="/"
    x=0 
    for part in $exploded
    do  
        final+="${ROYGBIV[$x]}$sep$part\e[0m"
        x=$(expr $x + 1)
    done
    printf $final
}
parse_git_branch() {
    local b=$(git symbolic-ref HEAD 2> /dev/null)
    if [ "${b#refs/heads/}" != "" ]
    then
        printf " \e[38;5;208m(${b#refs/heads/})\e[0m"
    fi
}
PS1='\[\033[45m\]\u\[\033[0;96m\] aws:\[\033[92m\]$AWS_DEFAULT_PROFILE`parse_git_branch` \[\033[37m\]- `color_path`\[\033[37m\]\n$ \[\033[0m\]'

Usage Screep Cap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caws-0.0.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

caws-0.0.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file caws-0.0.3.tar.gz.

File metadata

  • Download URL: caws-0.0.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for caws-0.0.3.tar.gz
Algorithm Hash digest
SHA256 523dffc0c3babff9d41c4465e7b01b94cbe464aa09a66a7bc52280632de85822
MD5 2387a41e894fbc723880bb2d7b8ca267
BLAKE2b-256 a27d6c7d980d930a1f0db7a1817080cc07c0bf26095ac49f823c04f1a9d0bfc6

See more details on using hashes here.

File details

Details for the file caws-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: caws-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for caws-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 11a1bf0fb1fa87f8b1b5a1382f9f871eb3457cfae77f18118b54108a7b11c6e6
MD5 f11c2858c0dc9d580f9e67323a09442b
BLAKE2b-256 8f828559e168826f78f7cb33f01baf67cb48bd0f69a938896f76e11d2bbaae38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page