Serverless-offline: Support for AWS credential profiles

Created on 18 Feb 2017  路  8Comments  路  Source: dherault/serverless-offline

It seems that when an application makes aws request outbound to aws services it only uses the default profile within ~/.aws/credentials. I did try setting export AWS_DEFAULT_PROFILE= as a workaround but that did not seem to work either.

Initially, I thought it should sue the serverless.yml provider details, but in fact I believe it's a better use case to have your "release" credentials separate from your "run" credentials. So I would recommend that a command line option to specify the profile or a separate setting in serverless.yml.

This also might be related to #189 as the region should be set in your .aws/config

enhancement help wanted

Most helpful comment

I also faced the same issue, using AWS_PROFILE as an environment variable is an ok workaround..
But I also think that a cli --profile flag should be supported, and ideally it should automatically use the defined profile in serverless.yaml which is already supported by the serverless framework like

provider:
  name: aws
  runtime: nodejs8.10
  profile: ${self:custom.aws_profile}

in serverless.yaml

All 8 comments

Updates:
Wrong environment variable. Instead use: export AWS_PROFILE=<profile> or
AWS_PROFILE=<profile> serverless offline

Maybe update the readme with the use of the environment variable and also add a --profile?

Hi @pkubat , sorry I must have missed this one u_u
Thanks for reporting this. A profile option would be a nice addition. Do you think you can PR anything, especially the README modification ?

Came here after struggling with the same feature.

Adding a --profile option (or a --aws-profile option to better reflect the serverless cli) could prove being more difficult than expected as sls invoke local does not have this particular option.

As you can see in the serverless docs an explicit exception is denoted about sls invoke local when explaining the different ways to include the aws profile. (See end of the document).

https://serverless.com/framework/docs/providers/aws/guide/credentials/

You can verify that this --aws-profile option is not present in sls invoke local

https://serverless.com/framework/docs/providers/aws/cli-reference/invoke-local/

I also faced the same issue, using AWS_PROFILE as an environment variable is an ok workaround..
But I also think that a cli --profile flag should be supported, and ideally it should automatically use the defined profile in serverless.yaml which is already supported by the serverless framework like

provider:
  name: aws
  runtime: nodejs8.10
  profile: ${self:custom.aws_profile}

in serverless.yaml

Thanks guys, I ran into this issue when I couldn't generate s3 presigned URLs locally. It should definitely use the provider profile if it's defined in the .yml

@im-danwu do you have some code or better a small repro to illustrate your issue?

Hey I don't have a simple set of code since the problem affects multiple parts of the app.

But my problem is pretty straightforward. My serverless.yml uses my serverless AWS profile creds to manage my AWS resources. When the app is up and running on AWS, the lambda functions use the same set of creds for accessing those resources. However, using serverless-offline, it wasn't loading those default credentials like I expected it to.

provider:
  name: aws
  runtime: nodejs12.x

  stage: ${opt:stage, 'dev'}
  region: ${opt:region, 'us-east-1'}
  profile: serverless

See the profile: serverless config above in my serverless.yml? I expected serverless-offline to load that profile.

I would expect serverless-offline to use the profile from serverless.yml... this would be a wonderful feature

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rafaelsk picture Rafaelsk  路  4Comments

dnalborczyk picture dnalborczyk  路  3Comments

ghost picture ghost  路  4Comments

stunningpixels picture stunningpixels  路  3Comments

davidroman0O picture davidroman0O  路  4Comments