Cached credentials for sls deploy command

I am caching my credentials with aws-vault but sls deploy still prompts for the MFA code. Is there a way to use the cached credentials instead of being prompted for MFA code always?

I haven’t used aws-vault, but I guess you should rely on this:

Using the equivalent on aws-vault to named profiles and login previously will allow you to use the option –aws-profile profileName when you execute any command with SLS CLI.

1 Like

You need to use aws-vault to write the temporary credentials to a temporary file (AWS_SHARED_CREDENTIALS_FILE) and then set AWS_SDK_LOAD_CONFIG=1 so it ends up looking a little like:

AWS_SHARED_CREDENTIALS_FILE="$(pwd)/.credentials" AWS_SDK_LOAD_CONFIG=1 serverless deploy --stage staging --aws-profile <profile-name>

1 Like