如何在AWS Lambda上使用环境变量? [英] How can I use environmental variables on AWS Lambda?
问题描述
但是,我找不到一种为AWS Lambda实例设置环境变量的方法。任何人都可以指向正确的方向吗?
如果不可能使用环境变量,您可以建议一种方法来使用环境变量进行本地开发,并将其转换为有效的配置系统,可以使用AWS中的应用程序代码访问。
谢谢。
截至2016年11月18日,AWS Lambda 支持环境变量。
环境变量可以是指定都使用AWS控制台和AWS CLI。这就是您将如何使用AWS CLI创建具有 LD_LIBRARY_PATH
环境变量的Lambda:
aws lambda create-function \
--region us-east-1
--function-name myTestFunction
--zip文件fileb:// path / package。 zip
--role role-arn
--environment变量= {LD_LIBRARY_PATH = / usr / bin / test / lib64}
--handler index.handler
--runtime nodejs4 .3
--profile default
I'm writing an application which I want to run as an AWS Lambda function but also adhere to the Twelve-Factor app guidelines. In particular Part III. Config which requires the use of environmental variables for configuration.
However, I cannot find a way to set environmental variables for AWS Lambda instances. Can anyone point me in the right direction?
If it isn't possible to use environmental variables can you please recommend a way to use environmental variables for local development and have them transformed to a valid configuration system that can be accessed using the application code in AWS.
Thanks.
As of November 18, 2016, AWS Lambda supports environment variables.
Environment variables can be specified both using AWS console and AWS CLI. This is how you would create a Lambda with an LD_LIBRARY_PATH
environment variable using AWS CLI:
aws lambda create-function \
--region us-east-1
--function-name myTestFunction
--zip-file fileb://path/package.zip
--role role-arn
--environment Variables={LD_LIBRARY_PATH=/usr/bin/test/lib64}
--handler index.handler
--runtime nodejs4.3
--profile default
这篇关于如何在AWS Lambda上使用环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!