如何在Elastic Beanstalk中的值中设置带有'$'的环境变量? [英] How to set an environment variable with a '$' in the value in Elastic Beanstalk?

查看:100
本文介绍了如何在Elastic Beanstalk中的值中设置带有'$'的环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入一个带有美元符号$的值时,环境仅读取它的第一部分,这是因为生成的env文件在值中使用双引号而不是单引号.可以解决吗?该值无法更改,因为它是我无法控制的服务的访问令牌.

When I enter a value that has a dollar sign $ the environment only reads the first part of it, and that's because the env file generated puts double quotes in the values instead of single quotes. Any way around that? The value can't be changed because it's an access token from a service I don't control.

示例:

生成的环境文件类似于: export MY_VAR="my$value"

The env file generated is like: export MY_VAR="my$value"

运行该结果将导致: MY_VAR=my

Running that results in: MY_VAR=my

推荐答案

可以使用三个反斜杠来使美元符号转义(使用Web控制台或命令行均可):

Either escape the dollar signs with three backslashes (works using either the web console or the command line):

eb setenv -e my-environment MY_VARIABLE=\\\$foobar

或者使用强引号(''),您只需使用一个反斜杠即可转义:

Or with a strong quotes ('') you would only have to use one backslash to escape:

eb setenv -e my-environment MY_VARIABLE='\$foobar'

这篇关于如何在Elastic Beanstalk中的值中设置带有'$'的环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆