# Framework is ignoring profile (AWS account) settings (per stage profile)

**URL:** <https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613>\
**Category:** Serverless Framework\
**Created:** [May 30, 2018, 4:14pm UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613 "2018-05-30T16:14:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/pawel/32/1850_2.png) [@Pawel](https://forum.serverless.com/u/Pawel)\
**Post date:** [May 30, 2018, 4:14pm UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/1 "2018-05-30T16:14:50Z")

</div>

I want Serverless Framework to deploy stack to 2 different AWS accounts depending on stage.

My .aws\credentials looks like that:

```auto
[default]
aws_access_key_id = AKI....
aws_secret_access_key = Lwx....
[testAccount]
aws_access_key_id = AKI...
aws_secret_access_key = 7pjV....
[prodAccount]
aws_access_key_id = AK....
aws_secret_access_key = Lw....

```

and my serverless.yml looks like that:

```auto
custom:
  myStage: ${opt:stage, self:provider.stage}
  myProfile:
    dev: testAccount
    prod: prodAccount
  myRegion:
    dev: eu-west-1 # Ireland
    prod: us-west-2 # Oregon

provider:
  name: aws
  stage: dev
  runtime: nodejs8.10
  profile: ${self:custom.myProfile.${self:custom.myStage}}
  region: ${self:custom.myRegion.${self:custom.myStage}}

```

**Both `sls deploy --stage prod` & `sls deploy` commend deploy stack to the `[default]` account.**

I saw similar config in docs [https://serverless.com/framework/docs/providers/aws/guide/credentials#per-stage-profiles](https://serverless.com/framework/docs/providers/aws/guide/credentials#per-stage-profiles)

What am I doing wrong?

PS. What’s also strange is that regions are properly handled.

```auto
sls -v
1.26.1

```

---

<div class="post-metadata">

**Author:** ![willKo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/willko/32/1239_2.png) [@willKo](https://forum.serverless.com/u/willKo)\
**Post date:** [June 3, 2018, 12:14am UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/2 "2018-06-03T00:14:56Z")

</div>

I think you need to set an environment varable called “AWS\_PROFILE” [1][2].  
This should help the aws cli to use the profile you want.

[1] [https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html](https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html)  
[2] [https://serverless.com/framework/docs/providers/aws/guide/variables/](https://serverless.com/framework/docs/providers/aws/guide/variables/)

---

<div class="post-metadata">

**Author:** ![Pawel](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/pawel/32/1850_2.png) [@Pawel](https://forum.serverless.com/u/Pawel)\
**Post date:** [June 3, 2018, 4:03pm UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/3 "2018-06-03T16:03:57Z")

</div>

@willKo I don’t think so. It used to work without environment varable correctly.

---

<div class="post-metadata">

**Author:** ![timmyg](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/timmyg/32/2078_2.png) [@timmyg](https://forum.serverless.com/u/timmyg)\
**Post date:** [June 12, 2018, 1:48am UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/4 "2018-06-12T01:48:08Z")

</div>

@Pawel I am having the same issue. Tried removing serverless and reinstalling but same issue (specifying an an aws profile, but deploying to my main aws account)

---

<div class="post-metadata">

**Author:** ![robertdavidrowland](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/robertdavidrowland/32/1986_2.png) [@robertdavidrowland](https://forum.serverless.com/u/robertdavidrowland)\
**Post date:** [June 12, 2018, 2:34pm UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/5 "2018-06-12T14:34:54Z")

</div>

I deploy to two different stacks without any problems, but I do have a slightly different setup:

```
custom:
  ${file(env/${opt:stage, 'dev'}.yml)}

provider:
  ..
  profile: ${self:custom.profile}
  ..

```

In dev.yml I have

```
profile: "dev"

```

And in prd.yml I have

```
profile: "prd"

```

Obviously my default and prd profiles are set up in point to separate accounts in .aws/credentials

---

<div class="post-metadata">

**Author:** ![timmyg](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/timmyg/32/2078_2.png) [@timmyg](https://forum.serverless.com/u/timmyg)\
**Post date:** [June 12, 2018, 6:06pm UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/6 "2018-06-12T18:06:41Z")

</div>

@Pawel my issue ended up being that I was looking for them in the aws web gui, but was looking in the wrong region 🤦‍♂️

---

<div class="post-metadata">

**Author:** ![dhavalyours](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dhavalyours/32/1183_2.png) [@dhavalyours](https://forum.serverless.com/u/dhavalyours)\
**Post date:** [June 15, 2018, 6:54am UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/7 "2018-06-15T06:54:52Z")

</div>

The way how we work in our environment is we do not hard code the stage or region in the serverless.yml file. It is passed via the deploy command.

**Command line to deploy :**

serverless deploy --stage dev --region us-east-1 --profile awsDev

**Sample Serverless.yml File**

```
service: xyz

provider:
  name: aws
  runtime: nodejs6.10
  memorySize: 1024
  environment:
    XXX: ${ssm:/${self:custom.stage}/xxx~true}
    
custom:
  stage: ${opt:stage, self:provider.stage}
  
functions:
  testMe:
    handler: handler.xyz
    onError: ${self:provider.environment.XXX}
    access: public
    events:
      - http:
          path : myApi
          method : get
```

---

<div class="post-metadata">

**Author:** ![ejdoh1](https://avatars.discourse-cdn.com/v4/letter/e/b77776/32.png) [@ejdoh1](https://forum.serverless.com/u/ejdoh1)\
**Post date:** [January 23, 2019, 1:44am UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/8 "2019-01-23T01:44:39Z")

</div>

@Pawel did you find a fix?

---

<div class="post-metadata">

**Author:** ![Emrys](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@Emrys](https://forum.serverless.com/u/Emrys)\
**Post date:** [March 13, 2020, 4:54pm UTC](https://forum.serverless.com/t/framework-is-ignoring-profile-aws-account-settings-per-stage-profile/4613/9 "2020-03-13T16:54:22Z")

</div>

I tried absolutely everything to persuade serverless to use a profile from my aws-cli credentials. Absolutely nothing worked at all.

I had linked my web serverless dashboard to my serverless CLI, and that created a default profile for deployment. It turned out that the serverless CLI was using that default profile from the web dashboard for all my stage deployments, despite specifying a different profile everywhere else. The only way I found to override it was to establish a second profile in the web dashboard, link it with the right AWS account in the web dashboard, and explicitly set that profile to be used for the right stage in the web dashboard.

–aws-profile in the serverless CLI, AWS\_PROFILE= in the serverless CLI, and profile: in serverless.yml, had absolutely no effect. This is with the latest code in 2020-03.
