当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - Amazon ElasticBeanstalk: configure environment variable with newlines

问题描述:

I want to add environment variable with newlines to my application using ElasticBeanstalk such as RSA private key. I have the following form for this purpose:

and AWS CLI as well.

网友答案:

I didn't want to add a key file to my build, as we build from git, and keys in version control can be a security hazard, so I used this workaround instead:

# From your shell: Base64 encode the RSA private key file
# -w 0 disables wrapping, we don't want new lines
base64 -w 0 id_rsa

Base64 encoded data doesn't have newlines, so you can use the output directly as an ElasticBeanstalk environment variable. You can then use this variable inside your application like so:

# From the shell
echo "$SSH_PRIVATE_KEY" | base64 --decode - > .ssh/id_rsa
# Or just decode it with some other programming language of your choice

This way, you don't have to include the file that you're referencing into your build, but you can contain the key completely in the environment variable.

分享给朋友:
您可能感兴趣的文章:
随机阅读: