Storing IAM credentials securely
Granted can securely store IAM credentials traditionally stored in plaintext in the AWS credentials file ~/.aws/credentials
.
Granted uses the system keychain to securely store credentials and falls back to an encrypted file on systems where this is not available.
add
command
Add new credentials directly via the command line.
Example Usage
You should see an output like the following:
This stores the credentials in secure storage and creates a new entry in your local AWS config file that looks like this.
You can now assume the profile by running assume example
import
command
Importing allows you to import existing credentials from your local AWS credentials file into secure storage.
Example Usage
This command will write an output similar to the following to ~/.aws/config
:
You can now assume the profile by running assume example
import-from-env
command
The import-from-env
command enables you to create a new AWS config profile with IAM credentials imported from environment.
Example Usage
Upon execution, this command will generate an AWS configuration profile named my-profile. The credentials for this profile will be sourced from the following environment variables:
$AWS_ACCESS_KEY_ID
: Your AWS access key ID.$AWS_SECRET_ACCESS_KEY
: Your AWS secret access key.
update
command
Update credentials stored in secure storage.
Example Usage
You should see an output like the following:
list
command
This will list profile names of the credentials stored in secure storage.
Example Usage
remove
command
This will remove credentials from secure storage. If there is a profile configured under the same name, the CLI will check whether it has a credential-process entry. For example
If this is the case, the profile will also be removed. If it does not have this entry, the profile will not be modified and the credentials will be removed from the secure storage.
Example Usage
Example Usage —all
This will clear all credentials from secure storage.
export-plaintext
command
This command can be used to return your credentials to the original insecure plaintext format in the AWS credentials file. The credentials will not be removed from secure storage, however the profile configuration in the AWS config file will be updated to use the plaintext credentials rather than the credentials in the secure storage.
Example Usage
This command will write an entry similar to the following in your AWS credentials file.
It will also remove the credential_process
entry from the profile in the AWS config file.
Using IAM Credentials with Multi-Factor Authentication (MFA)
For those using an AWS profile that requires an MFA prompt, Granted will cache your credentials, eliminating the need to repeatedly enter the MFA token code as long as the cached credentials remain valid.
Moreover, if you can obtain an MFA token through a script, you can now utilize the mfa-token
flag with assume
to bypass the MFA prompt like assume dev --mfa-token 123456