1

On PowerShell, I defined two environment variables to define AWS secret and access key:

$AWS_ACCESS_KEY_ID="AAAA"
$AWS_SECRET_ACCESS_KEY="CCCC"

PS C:\Users\Obaid\serverless\helloJava> serverless deploy
Serverless: Packaging service...

Serverless Error ---------------------------------------

ServerlessError: AWS provider credentials not found.
Learn how to set up AWS provider credentials in our docs (...)

Why serverless dosent pick my credentials?

Mike Doe
  • 16,349
  • 11
  • 65
  • 88
obaid
  • 361
  • 3
  • 10

1 Answers1

2

You must set environment variables in powershell like so

$env:AWS_ACCESS_KEY_ID="AAAA"
$env:AWS_SECRET_ACCESS_KEY="CCCC"
Richie Mackay
  • 1,385
  • 10
  • 12
  • Actually, I am getting the following errors irrespective of wether I provide the environment variables or not, Actually my company blocks the credentials file on my CI/CD tool, so these credentials are not accessible on disk : `Serverless plugin "/opt/node/node-v5.10.0-linux-x64/lib/node_modules/serverless/lib/plugins/aws/configCredentials/awsConfigCredentials.js" initialization errored: EACCES: permission denied, open '/home/jenkins/.aws/credentials'` – obaid Jan 31 '18 at 05:24
  • Not sure what your powershell issue has to do with jenkins running on linux unless you are running powershell on there. There are multiple ways to pass creds though. You could try setting these up as variables in the build projects that are passed to your jenkins agent. – Richie Mackay Jan 31 '18 at 08:48
  • Also unsure what awsC‌​onfigCredentials.js is doing you really shouldn't need to configure them. Here is a page that explains the multiple way you can pass creds to the aws sdk (or rather have the sdk pick them up) https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html (see links at bottom) – Richie Mackay Jan 31 '18 at 08:50
  • Thanks, I think I need to pass credentials to jenkins agent, actually we use Jenkins pipeline, write jenkins functions, and that function is calling 'serverless deploy'. SO I found out that the credentials were not properly set, which is why serverless might be looking into the .aws/credentials file – obaid Feb 01 '18 at 03:13
  • PowerShell I used for testing purpose, it dosent have to do anything with the actual issue I was having with JenkinsPipeline function – obaid Feb 01 '18 at 03:16
  • Serverless just uses the AWS SDK. It doesn't do any voodoo. If you can deploy locally with the credentials you have, it should work on Jenkins with the same ones as long as the SDK can pick them up. TBH this is all a bit outside of the scope of the original question which I believe I answered. If you have a specific question regarding the Jenkins setup perhaps ask another one. – Richie Mackay Feb 01 '18 at 08:55