Environment variables not working - different AWS keys returned
See original GitHub issueThis is a Bug Report
Description
For bug reports:
- What went wrong?
I assign env vars in
serverless.yml
but get back different vars fromprocess.env
- What did you expect should have happened? I expected to get back the vars that I set
- What was the config you used? I’m using node-s3-client to upload file to S3
- What stacktrace or error message from your provider did you see?
unable to upload: InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records.
at Request.extractError (/var/task/node_modules/aws-sdk/lib/services/s3.js:343:35)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:100:18)
at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:604:14)
at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:21:12)
at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:22:9)
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:606:12)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:104:18)
I set my own AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in serverless.yml
like:
provider:
name: aws
runtime: nodejs4.3
functions:
hello:
handler: handler.hello
events:
- http: GET hello
environment:
AWS_ACCESS_KEY_ID: <MY-ACCESS-KEY-ID>
AWS_SECRET_ACCESS_KEY: <MY-SECRET-ACCESS-KEY>
but process.env.AWS_ACCESS_KEY_ID
and process.env.AWS_SECRET_ACCESS_KEY
return different values, not even from my own AWS account.
If I place the keys directly in handler.js
access to AWS is granted and the upload works fine.
Also, I’m invoking these function from the Serverless Mac app. Just in case that makes a difference.
Is this likely an issue with the NPM module or is it a framework issue?
Additional Data
- Serverless Framework Version you’re using:
- Operating System: OS X 10.11.5
- Stack Trace:
- Provider Error messages:
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Environment variables to configure the AWS CLI
Environment variables provide another way to specify configuration options and credentials, and can be useful for scripting or temporarily setting a named ...
Read more >Authenticating to AWS with Environment Variables
Another way to authenticate to AWS on the CLI is to set your Access Keys as the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY :...
Read more >Can use AWS CLI with credentials file but not ... - Stack Overflow
In case someone stumbles on this, a possible culprit for this might be the AWS_SESSION_TOKEN and AWS_SECURITY_TOKEN environment variables. If ...
Read more >Never put AWS temporary credentials in the ... - Ben Kehoe
Other issues ask for setting environment variables, which isn't much better. The actual AWS standard for credential resolution is much richer ...
Read more >Working with Environment Variables in Java - Twilio
util.Map containing all environment variables and their values is returned. The Map's keys are the environment variable names and its values are ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve just gotten the same -
undefined
I have this same issue I don’t know how. It returns
undefined
. Any workarounds?