ngydv creates aws cli session keys with mfa-token and stores, exports it.
bash
cargo install ngydv
You need aws cli configuration file ~/.aws/config and ~/.aws/credentials.
And at more file at ~/.aws/ngydv to store your mfa device arn, if needed.
```~/.aws/ngydv
[profilea] mfadevice = arn:aws:iam::nnnnnnnnnnnn:mfa/user_name ```
Creates session or assume role based on profile type and store it in ~/.aws/ngydv_credentials.yaml.
And prints commands to export the keys and token, so use like this.
```bash
source <(ngydv in profile_a 000000)
. <(ngydv in profile_a 000000) ```
Creates session for profile like this.
``` .aws/credentials
[profilea] awsaccesskeyid = XXXXXXXXXXXXXXXXXXXX awssecretaccess_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ```
``` .aws/config
[profile_a] output = yaml region = ap-northeast-1 ```
```~/.aws/ngydv
[profilea] mfadevice = arn:aws:iam::nnnnnnnnnnnn:mfa/user_name ```
Assume role for profile like this.
``` .aws/config
[profileb] region = ap-northeast-1 rolearn = arn:aws:iam::nnnnnnnnnnn:role/rolename mfaserial = arn:aws:iam::mmmmmmmmmmmm:mfa/user-name sourceprofile = base_profile ```
This sub command prints sh commands to export stored session tokens.
The output is same as 'in' sub command, but no need to input mfa token again. This sub command is to switch between multi user profile or multi aws account.
``` source <(ngydv export profile)
. <(ngydv export profile) ```
Clears stored sessions in ~/.aws/ngydv_credentials.yaml.
ngydv clear session
Clears environment variables related AWS CLI command.
``` . <(ngydv clear env)
source <(ngydv clear env) ```
List available profiles.
$ ngydv profile
id | profile | region | type | credential
----+-----------+----------------+----------------------------+---------------------------------------
1 | default | ap-northeast-2 | Access key | -
2 | hpm | ap-northeast-1 | Access key with mfa device | expired at 2020-05-06 00:02:01 +09:00
3 | hpmadm | ap-northeast-1 | Assume role from hpm | -
Shows current default profile
``` $ ngydv show 1. checking AWSACCESSKEYID and AWSACCESSKEYID. environment variables are not set. 2. checking AWS_PROFILE. environment variable is not set. 3. checking profile named 'default'.
use profile "default" as default. ```
List environment variables related AWS CLI.
$ ngydv env
name | desc | default | value
-----------------------------+------------------------------------------------------------------------------------------+--------------------+------------------------------------------
AWS_ACCESS_KEY_ID | AWS access key associated with an IAM user or role | | XXXXXXXXXXXXXXXXXXXX
AWS_CA_BUNDLE | The path to a certificate bundle to use for HTTPS certificate validation | |
AWS_CONFIG_FILE | The location of the file that the AWS CLI uses to store configuration profiles | ~/.aws/config |
AWS_DEFAULT_OUTPUT | The output format to use | json |
AWS_DEFAULT_REGION | The AWS Region to send the request to | |
AWS_PAGER | The pager program used for output | |
AWS_PROFILE | The name of the CLI profile with the credentials and options to use | default |
AWS_ROLE_SESSION_NAME | A name to associate with the role session | |
AWS_SECRET_ACCESS_KEY | The secret key associated with the access key | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AWS_SESSION_TOKEN | The session token value that is required if you are using temporary security credentials | |
AWS_SHARED_CREDENTIALS_FILE | The location of the file that the AWS CLI uses to store access keys | ~/.aws/credentials |