将 .env 环境变量上传到弹性 beantalk [英] Upload .env environment variables to elastic beanstalk

查看:30
本文介绍了将 .env 环境变量上传到弹性 beantalk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,将环境变量设置为弹性 beantalk 的唯一方法是:

As far as I know the only way to set environment variables to elastic beanstalk is either:

  1. AWS 在线控制台.
  2. eb setenv 命令.

我的项目中有一个 .env 文件,其中包含超过 100 个变量的所有环境变量,我正在寻找一种方法将它们同时推送到 eb 实例.

I have a .env file in my project that contains all of my environment variables over 100 variables and I'm looking for a way to push them all to the eb instance at the same time.

推荐答案

首先,您应该注意 Elastic Beanstalk 对每个环境有五十 (50) 个环境变量的限制.

First off, you should note that Elastic Beanstalk has a limit of fifty (50) environment variables per environment.

现在,如果你在 .env 文件中设置了一堆环境变量,一个简单的设置它们的方法是像这样将它们全部转储到 eb setenv 命令中......

Now, if you've got a bunch of environment variables set in a .env file, an easy way to set them en-mass is to just dump them all into the eb setenv command like this...

eb setenv `cat .env | sed '/^#/ d' | sed '/^$/ d'`

这会将它们全部设置好,并节省您在 aws 控制台页面上花费一整夜的时间.sed 命令删除注释行和新行.

This will set them all in one shot and save you spending all night on the aws console page. The sed command remove commented lines and new lines.

解释外壳

这篇关于将 .env 环境变量上传到弹性 beantalk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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