/plugin-asp

Oh My Fish plugin for switching between AWS profiles. Supports both hard-coded keys and role assumption.

Primary LanguageShellMIT LicenseMIT

asp

A plugin for Oh My Fish.

MIT License Fish Shell Version Oh My Fish Framework


Enables quick switching between AWS profiles. Supports both hard-coded keys and role assumption. Works with the aws plugin by @sagebind.

Prerequisites

Install

$ omf install git@github.com:mgoodness/plugin-asp.git

Usage

$ asp <aws_profile> [region]

Sets $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY environment variables to the corresponding values from ~/.aws/credentials. If keys are not listed in the profile, attempts to assume the profile's role_arn and uses the returned keys. Also sets $AWS_DEFAULT_REGION and $AWS_DEFAULT_PROFILE. The optional region value can be used if you wish to override the default region configured in your ~/.aws/credential file..

$ agp

Echoes $AWS_DEFAULT_PROFILE and AWS_DEFAULT_REGION.

Example configuration

~/.aws/credentials

[default]
output = json
region = us-east-1
aws_access_key_id = <ACCESS_KEY>
aws_secret_access_key = <SECRET_KEY>

[prod]
output = json
region = us-east-1
role_arn = arn:aws:iam::<ACCOUNT_NUMBER>:role/<PROD_ROLE_NAME>
source_profile = default

[stage]
output = json
region = us-east-1
role_arn = arn:aws:iam::<ACCOUNT_NUMBER>:role/<STAGE_ROLE_NAME>
source_profile = default

Caveats

  • Role-based credentials expire after one hour.

License

MIT © Michael Goodness et al