# Use AWS SSO on sls

**URL:** <https://forum.serverless.com/t/use-aws-sso-on-sls/11521>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [May 21, 2020, 7:50pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521 "2020-05-21T19:50:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![franmemo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/franmemo/32/4040_2.png) [@franmemo](https://forum.serverless.com/u/franmemo)\
**Post date:** [May 21, 2020, 7:50pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/1 "2020-05-21T19:50:51Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![conradperes](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/conradperes/32/4276_2.png) [@conradperes](https://forum.serverless.com/u/conradperes)\
**Post date:** [May 26, 2020, 2:42am UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/2 "2020-05-26T02:42:12Z")

</div>

Did you do with Cognito? I could connect and use sso with kotlin, but without sls.

---

<div class="post-metadata">

**Author:** ![sime](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/sime/32/230_2.png) [@sime](https://forum.serverless.com/u/sime)\
**Post date:** [May 26, 2020, 1:37pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/3 "2020-05-26T13:37:24Z")

</div>

I guess it’s a side effect of how you are logging into SSO?

With Google AWS SSO, this CLI worked for me.

> **[ruimarinho/gsts](https://github.com/ruimarinho/gsts)**
>
> Obtain and store AWS STS credentials to interact with Amazon services by authenticating via G Suite SAML. - ruimarinho/gsts

---

<div class="post-metadata">

**Author:** ![mgleria](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mgleria/32/4410_2.png) [@mgleria](https://forum.serverless.com/u/mgleria)\
**Post date:** [May 26, 2020, 2:13pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/4 "2020-05-26T14:13:07Z")

</div>

I’m having the same issue. I’m working with 15+ AWS Accounts and I’m logging trough CLI with:  
`aws sso login --profile profileName`

Does anyone have a clue on how to tell to serverless to work with AWS SSO?

---

<div class="post-metadata">

**Author:** ![franmemo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/franmemo/32/4040_2.png) [@franmemo](https://forum.serverless.com/u/franmemo)\
**Post date:** [May 26, 2020, 2:27pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/5 "2020-05-26T14:27:00Z")

</div>

for now the only solution I have is to login with sso on the web page and import the temp credentials on the terminal

---

<div class="post-metadata">

**Author:** ![franmemo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/franmemo/32/4040_2.png) [@franmemo](https://forum.serverless.com/u/franmemo)\
**Post date:** [May 26, 2020, 2:31pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/6 "2020-05-26T14:31:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mgleria](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mgleria/32/4410_2.png) [@mgleria](https://forum.serverless.com/u/mgleria)\
**Post date:** [May 26, 2020, 2:49pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/8 "2020-05-26T14:49:53Z")

</div>

Yes, you are right. It seems that sls does not support AWS SSO credentials.

> **[Serverless Framework - AWS Lambda Guide - Credentials](https://www.serverless.com/framework/docs/providers/aws/guide/credentials/)**
>
> How to set up the Serverless Framework with your Amazon Web Services credentials

That could be related or not?

---

<div class="post-metadata">

**Author:** ![warrickhill](https://avatars.discourse-cdn.com/v4/letter/w/a4c791/32.png) [@warrickhill](https://forum.serverless.com/u/warrickhill)\
**Post date:** [July 15, 2020, 12:56pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/9 "2020-07-15T12:56:40Z")

</div>

Hi. I had the same problem with Terraform. I made a help util to setup profiles in `~/.aws/credentials` from SSO for me, [https://github.com/PredictMobile/aws-sso-credentials-getter](https://github.com/PredictMobile/aws-sso-credentials-getter).

---

<div class="post-metadata">

**Author:** ![franmemo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/franmemo/32/4040_2.png) [@franmemo](https://forum.serverless.com/u/franmemo)\
**Post date:** [July 17, 2020, 7:29pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/11 "2020-07-17T19:29:05Z")

</div>

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.-

---

<div class="post-metadata">

**Author:** ![benno001](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/benno001/32/4294_2.png) [@benno001](https://forum.serverless.com/u/benno001)\
**Post date:** [July 20, 2020, 8:01am UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/12 "2020-07-20T08:01:12Z")

</div>

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.

> **[victorskl/yawsso](https://github.com/victorskl/yawsso)**
>
> Yet Another AWS SSO - sync up AWS CLI v2 SSO login session to legacy CLI v1 credentials - victorskl/yawsso

---

<div class="post-metadata">

**Author:** ![mgleria](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mgleria/32/4410_2.png) [@mgleria](https://forum.serverless.com/u/mgleria)\
**Post date:** [August 18, 2020, 3:53pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/13 "2020-08-18T15:53:24Z")

</div>

The issue was opened: [https://github.com/serverless/serverless/issues/7567](https://github.com/serverless/serverless/issues/7567)

And it seems that depends on an AWS issue: [https://github.com/aws/aws-sdk-js/issues/2772](https://github.com/aws/aws-sdk-js/issues/2772)

It looks like we will have to wait for a native solution…

---

<div class="post-metadata">

**Author:** ![urz9999](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/urz9999/32/5056_2.png) [@urz9999](https://forum.serverless.com/u/urz9999)\
**Post date:** [January 13, 2021, 3:26pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/14 "2021-01-13T15:26:20Z")

</div>

Hello guys! Maybe you can check this project: [https://github.com/Noovolari/leapp](https://github.com/Noovolari/leapp)

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.

---

<div class="post-metadata">

**Author:** ![BorisVivienne](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@BorisVivienne](https://forum.serverless.com/u/BorisVivienne)\
**Post date:** [January 27, 2021, 3:42pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/15 "2021-01-27T15:42:29Z")

</div>

> [@warrickhill](#):
>
> Hi. I had the same problem with Terraform. I made a help util to setup profiles in `~/.aws/credentials` from SSO for me, [GitHub - PredictMobile/aws-sso-credentials-getter](https://github.com/PredictMobile/aws-sso-credentials-getter/) [work time](https://www.worktime.com/).

Hi! very usefull and clear!  
Thanks!

---

<div class="post-metadata">

**Author:** ![afrazkhan](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/afrazkhan/32/5945_2.png) [@afrazkhan](https://forum.serverless.com/u/afrazkhan)\
**Post date:** [July 3, 2021, 9:03pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/16 "2021-07-03T21:03:54Z")

</div>

Didn’t work for me. I have Ubuntu. This package only throwing the error **Profile not found**.  
I used after installing as: `ssocred default`

---

<div class="post-metadata">

**Author:** ![afrazkhan](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/afrazkhan/32/5945_2.png) [@afrazkhan](https://forum.serverless.com/u/afrazkhan)\
**Post date:** [July 3, 2021, 9:09pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/17 "2021-07-03T21:09:47Z")

</div>

I have followed all methods explained in the above thread but no success. Any one here with a solution/ workaround for this with clear steps.  
thanks.

---

<div class="post-metadata">

**Author:** ![byzhang](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@byzhang](https://forum.serverless.com/u/byzhang)\
**Post date:** [December 12, 2022, 7:06am UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/19 "2022-12-12T07:06:48Z")

</div>

According to this discussion [Issue #7567](https://www.notion.so/image/https%3A%2F%2Fwww.notion.so%2Fimages%2Fexternal_integrations%2Fgithub-icon.png?width=200&userId=&cache=v2), sls doesn’t support aws SSO natively, and [serverless-better-credentials plugin](https://www.npmjs.com/package/serverless-better-credentials) is the best workaround so far.

---

<div class="post-metadata">

**Author:** ![byzhang](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@byzhang](https://forum.serverless.com/u/byzhang)\
**Post date:** [December 14, 2022, 2:34am UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/20 "2022-12-14T02:34:55Z")

</div>

According to the latest replies to the [github issue](https://github.com/serverless/serverless/issues/7567) shared above, the best solution so far is to use a plugin

> **[serverless-better-credentials](https://www.npmjs.com/package/serverless-better-credentials)**
>
> Better AWS credentials resolution plugin for serverless. Latest version: 1.1.3, last published: 4 months ago. Start using serverless-better-credentials in your project by running \`npm i serverless-better-credentials\`. There are no other projects in...

---

<div class="post-metadata">

**Author:** ![Rhineb](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rhineb/32/7451_2.png) [@Rhineb](https://forum.serverless.com/u/Rhineb)\
**Post date:** [May 5, 2023, 6:28pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/21 "2023-05-05T18:28:41Z")

</div>

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](https://www.npmjs.com/package/aws-sso-creds-helper) 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

---

<div class="post-metadata">

**Author:** ![williamOodle](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/williamoodle/32/7467_2.png) [@williamOodle](https://forum.serverless.com/u/williamOodle)\
**Post date:** [May 12, 2023, 12:46pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/22 "2023-05-12T12:46:41Z")

</div>

Hi Rhineb,

I went in the same issue with you before, in my case, I was using `aws configure sso` and in `~/.aws/config`, I have a `sso_session` in my profile.

After removing the `sso_session` (& `~/.aws/credentials` if existed), `Serverless-better-credentials` works for me.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![mmarcotte](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/mmarcotte/32/7612_2.png) [@mmarcotte](https://forum.serverless.com/u/mmarcotte)\
**Post date:** [August 17, 2023, 6:24pm UTC](https://forum.serverless.com/t/use-aws-sso-on-sls/11521/23 "2023-08-17T18:24:02Z")

</div>

[This comment](https://github.com/serverless/serverless/issues/7567#issuecomment-1666093707) 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:

package.json:

```auto
{
  "scripts": {
    "deploy": "eval $(aws configure export-credentials --profile ${AWS_PROFILE} --format env) && env -u AWS_PROFILE sls deploy --stage",
  }
}

```

Perform Deployment to production stage:

```auto
npm run deploy production

```

[Next page](https://forum.serverless.com/t/use-aws-sso-on-sls/11521.md?page=2)
