Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when invoking locally without credentials #8

Closed
adamhl8 opened this issue Sep 7, 2022 · 6 comments
Closed

Error when invoking locally without credentials #8

adamhl8 opened this issue Sep 7, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@adamhl8
Copy link

adamhl8 commented Sep 7, 2022

If I invoke locally without any AWS credentials, e.g. sls invoke local --function foo, an error is thrown:
Error: ENOENT: no such file or directory, open '~/.aws/credentials'

A workaround for this is to just create invalid AWS credentials:
serverless config credentials --provider aws --key NA --secret NA

The obvious answer is that I should just have actual credentials, but I don't think the plugin should throw an error if no credentials are found when invoking locally.

@adamhl8 adamhl8 added the bug Something isn't working label Sep 7, 2022
@thomasmichaelwallace
Copy link
Owner

Hey there- thanks for reporting.

It's definitely an interesting edge case; I'll admit I don't actually use invoke local, and as far as I'm aware it's impossible for a deployed lambda to run without any credentials (even if they're just for a role which isn't doing anything).

As you note - mixing in some credentials (either using the cli arguments, or you could have a default profile configured or enviornment variables) is a workaround.

I'm not against a PR - although it's quite possible the error is being thrown from the aws-sdk itself - but I don't have the bandwidth to fix it myself.

@thomasmichaelwallace
Copy link
Owner

I'm going to close this as a bit of house keeping.

Thanks again for reporting, though.

@throrin19
Copy link

Hey, I have the same problem. I use this plugin to try to deploy my app using aws SSO. But I develop using serverless-offline.

Whith this plugin, it's not possible to use serverless-offline. I have an error on credentials or profile

@aldenquimby
Copy link
Contributor

aldenquimby commented Sep 14, 2023

I am running into the same issues as @throrin19

@thomasmichaelwallace what are your thoughts on a PR that no-ops this plugin if the IS_OFFLINE env variable is set? That's what serverless-offline uses to signal it's running

@thomasmichaelwallace
Copy link
Owner

I don't have a problem with it, if it works.

The interaction between plugins and credentials is weirdly complicated; especially now some plugins are based on v3 of the AWS-SDK.

Something else to try is the workaround I've added to the troubleshooting stage, where you provide a credentials file:

https://github.com/thomasmichaelwallace/serverless-better-credentials?tab=readme-ov-file#troubleshooting

@aldenquimby
Copy link
Contributor

@thomasmichaelwallace PR for you here! #33

I plan to use this to enable everywhere except local, where I don't need AWS creds:

params:
  default:
    better-credentials-enabled: true
  local:
    better-credentials-enabled: false

plugins:
  - serverless-better-credentials

custom:
  betterCredentials:
    enabled: ${param:better-credentials-enabled}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants