Comments (8)
Are you using the -e
flag to pass the env variables to docker?
Try docker run -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY run -v "$PWD/dist":/var/task lambci/lambda
That will use whatever those variables are set to in your current env. If you want to supply a specific value, use -e AWS_ACCESS_KEY_ID=whatever
from docker-lambda.
Closing as it seems the root cause of the issue has been found π
from docker-lambda.
Damn it, I completely forgot about the -e
option :) Thanks, for the advice.
Looks like it works now!
But I still don't understand why NodeJS
could not get them from the .env
file. They are listed there. Why they were not available for the application?
Thanks!
from docker-lambda.
It depends on how you're defining them. Are you doing it outside of the Lambda function, at the top-level during require time? Those variables are overridden each time Lambda executes βΒ this is true in the live Lambda environment too βΒ so unless you define them in your function body (which is not a good idea β you should manage your credentials using IAM in Lambda) β they will be overridden by the Lambda environment (or in this case, by the docker-lambda controlling code)
from docker-lambda.
Oh, I did not know that.
I'm doing it like that
var main = function (ctx, cb) {
// load .env file and place variables into process.env.VARIABLE_NAME
require('dotenv').config();
...
exports.handler = function (e, ctx, cb) {
main(ctx, cb);
};
I'm sorry but
you should manage your credentials using IAM in Lambda
Could you please point me to the documentation page where I can see the description how to achieve that?
from docker-lambda.
See https://www.npmjs.com/package/dotenv#what-happens-to-environment-variables-that-were-already-set
from docker-lambda.
Lambda will already set your AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
variables β so you won't be able to override them using dotenv
.
Again, you really shouldn't be storing or loading these variables in Lambda itself (for testing it's fine, but you shouldn't be doing it via dotenv
β use the -e
flag)
Lambda will assign those variables using temporary IAM credentials based on the IAM role that the Lambda is running. That's where you should manage all of your Lambda permissions βΒ using the Role that you've assigned to the Lambda.
See more info here: http://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html
from docker-lambda.
Oh ok, now I got it.
Thank you.
from docker-lambda.
Related Issues (20)
- Missing files from provided.al2 HOT 1
- Need support for python3.9 HOT 10
- nodejs16.x support HOT 6
- Golang update to 1.17 HOT 1
- Is java11 image on AL2 and Corretto?
- How can I build image for python3.9 runtime? HOT 4
- Help with Debugging Go Lambda HOT 1
- Rebuild images? HOT 2
- What is the status of this project? HOT 7
- Make `myfunction` and `9001` configurable?
- Support for Node 14.x? HOT 1
- Boto3 and botocore need upgrading HOT 5
- Require image for ARM64 architecture
- Support for .NET 6
- Multi-arch support specially arm64 HOT 1
- Current ruby release (v2.7.2p137) out of date (now v2.7.6p?) HOT 1
- Missing .py file causing attributeError on lambda
- Jenkins agent install on lambci/lambda:build-python3.7 HOT 2
- Debugging with Pycharm
- [Question] Support for Provided Runtimes (Namely C++)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-lambda.