简体   繁体   English

使用无服务器框架时,我的环境变量被解析为数字

[英]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.

相关问题 为什么当表达式中有另一个长值时,我的整数文字没有被提升为long类型? - Why my integer literal is not being promoted to long type when there is another long value in the expression? 串联视频片段ffmpeg时显示错误:“ parsed_overlay_20之间的媒体类型不匹配” - when concatenating video segments ffmpeg shows error: “Media type mismatch between the parsed_overlay_20” 在AppleScript中使用函数时如何维护变量类型 - How to maintain variable type when using a function in applescript 为什么在将大于i32的数字存储到变量中时,我没有得到文字超出范围错误? - Why do I not get a literal out of range error when storing a number larger than an i32 into a variable? 使用 Type 变量转换变量 - Casting a variable using a Type variable React/TS/material-ui 使用变量作为网格属性的值会引发错误:“没有重载匹配”和“类型‘数字’不可分配给类型...” - React/TS/material-ui Using variable as value of grid property throws errors: "No overload matches" and "Type 'number' is not assignable to type..." 什么时候变量是 AnyObject 而不是 NSObject - When is a variable a AnyObject but not a NSObject 递增时变量溢出 - Variable overflow when increment 具有可变数量参数的函数的通用打字稿 - Typescript generic for function with a variable number of parameters 是否有测试字符串变量是否为数字值的函数? - Is there a function to test if a String variable is a number value?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM