'Use aws sso to execute sls commands

I am running below command to list all the CloudFormation stack outputs.

npx sls info --stage $STAGE --verbose

Upon executing I am getting below error

ProcessCredentialsProviderFailure: Profile default not found

I can definitely use aws access and secret keys to use sls commands but I am trying to achieve this using aws sso. SSO basically stores temporary credentials in ~/.aws/sso/cache/****.json, I am able to execute all other commands to communicate with aws using this method but somehow sls commands aren't working.

Any help is highly appreciated.



Solution 1:[1]

I got this to work by using serverless-better-credentials.

Install with:

npm install serverless-better-credentials

Then add to serverless.yml plugins, so that it appears first in the list:

plugins:
   - serverless-better-credentials

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 maxpaj