如何在Amazon EC2中设置环境变量 [英] How to set an environment variable in Amazon EC2

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

问题描述

我在我的EC2实例的AWS控制台上创建了一个标签。






$ b

同样的东西与弹性豆串起作用。 env 显示我在控制台上创建的标签。

  $ env 
[...]
DB_PORT = 5432

如何设置环境变量在Amazon EC2中

解决方案

按照 Guy ,我写了一个小shell脚本。该脚本使用AWS CLI和 jq 。它允许您将AWS实例和AMI标签导入shell环境变量。



希望可以帮助几个人。



https://github.com/12moons/ec2-tags-env


I created a tag on the AWS console for one of my EC2 instances.

However, when I look on the server, no such environment variable is set.

The same thing works with elastic beanstalk. env shows the tags I created on the console.

$ env
 [...]
 DB_PORT=5432

How can I set environment variables in Amazon EC2?

解决方案

Following the instructions given by Guy, I wrote a small shell script. This script uses AWS CLI and jq. It lets you import your AWS instance and AMI tags as shell environment variables.

I hope it can help a few people.

https://github.com/12moons/ec2-tags-env

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

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