Hello, I had configured SSO on my AWS accounts and I’m using the AWS CLI with it and everything works fine. My problem now is when I try to use serverless framework, it’s looks like sls don’t find the profiles configured with SSO, because they are not in the /.aws/credentials file, SSO use an access tokens to generate that temp credentials tokens stored in /.aws/sso/cache/****.json
There is a way to use SSO with sls, I would like to run the command ‘serverless deploy --stage dev’ and sls generate if it is necessary the new credentials.
The error Im getting:
Error: Profile dev-profile does not exist
at Object.addProfileCredentials (lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:101:15)
As far as I understand sls is looking for the credentials on the /.aws/credentials file and when you login using sso the credentials aren’t there. They are created on the fly using and api.
I don’t fully understand what are you using, gsts is a replacement for aws cli? because my problem is with sls not with aws cli, if I use aws cli directly its works fine.
Just if someone is facing the same error, what im doing for now is copy and pasting the “Command line or programmatic access” variables that AWS gives you (just next to the “Management console” link). Those have some expiration time, so you will need to do this each time you need to do something on the terminal but is not a big security risk. Any way it would be awesome to have this working correctly with SSO.-
I would love to have this working natively. As a workaround, I’m currently using ‘yawsso’ to sync SSO credentials. Works pretty well for multiple profiles.
Is not a solution per se on this issue but it’s a third party tool to help make AWS SSO compatible with AWS CLI v2 as well as many other tools that manage temporary credentials. It conects with your AWS SSO getting all your account and roles, then it creates temporary credentials and stores them in .aws/credentials instead of default aws sso path which is often not read by libraries or sdks.
I actually have not had luck with Serverless-better-credentials it would not work for me without manually copying the necessary aws creds to the .aws/credentials file.
What did work for me was this utility aws-sso-creds-helper - npm once installed just run the command and it will copy the necessary info to the credentials file then serverless will behave as expected so the following
aws sso login
ssocreds -p default
serverless deploy --aws-profile default
at least this is what has solved this issue for me as of 5/5/23
This comment on the Issue in the Serverless Repo was most helpful. I ended up adding a “deploy” script that utilizes the aws configure export-credentials command: