[英]When using the Serverless framework, my environment variable is being parsed as a number
I have an application which uses an environment variable. 我有一个使用环境变量的应用程序。 The environment variable itself is a bunch of numbers with a dot in the middle, eg
36478236853794287.234798237543893
, yet it should be interpreted as a string. 环境变量本身是一堆数字,中间带有一个点,例如
36478236853794287.234798237543893
,但应将其解释为字符串。 I want to deploy this application on AWS Lambda using the Serverless framework. 我想使用无服务器框架在AWS Lambda上部署此应用程序。
I have set the environment variable in a separate file ( secrets.yml
), which is .gitignored: 我已经在单独的文件(
secrets.yml
)中设置了环境变量,该文件被.gitignored:
dev:
MY_ENV_VAR: 36478236853794287.234798237543893
I then included it in serverless.yml
like this: 然后,我将其包含在
serverless.yml
如下所示:
provider:
environment: ${self:custom.secrets}
custom:
stage: ${opt:stage, self:provider.stage}
secrets: ${file(secrets.yml):${self:custom.stage}}
However, when I print out MY_ENV_VAR
in my application, the log shows it as a scientifically formatted number, like '3.6478236853794287E14'
. 但是,当我在应用程序中打印出
MY_ENV_VAR
时,日志将其显示为科学格式的数字,例如'3.6478236853794287E14'
。
The value as defined in the YAML file is being interpreted as a number. YAML文件中定义的值被解释为数字。 Enclose it in single quotes to make it explicit that it's a string:
将其用单引号引起来,以明确表明它是字符串:
dev:
MY_ENV_VAR: '36478236853794287.234798237543893'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.