node.js - 如何在 typescript 中获取我的个人资料的 aws 区域
问题描述
我在 .aws/config 中为特定的 aws 配置文件配置了我的 aws 区域。
是否可以在我的 node.js 服务中获取设置区域(例如 us-west-1)的值?
是否有我可以读取的环境变量?
解决方案
您可以运行aws configure get region
以获取默认配置文件的区域。
如果您添加--profile
,您将获得该特定配置文件的区域aws configure get region --profile otherprofile
。
您可以使用exec
从 nodejs 运行命令。
const { exec } = require('child_process')
exec('aws configure get region', (err, stdout, stderr) => {
const region = stdout
console.log(region)
})
但我认为最好将该区域保存为环境变量并从那里读取。
推荐阅读
- java - LibGdx 数组上的 Java NotSerializable 异常
- swift - UIButton 状态在滚动带有多个部分的 tableview 时发生变化 - Swift
- javascript - HTML CSS 表单的输入字段中的文本之间没有默认空格
- c - C - realloc():遇到无效指针错误
- android - 如何根据screenHeight来区分Layout?
- java - Spring Boot REST CRUD - 如何发布具有一对一关系的实体?
- spring - 具有弹簧安全性的开放休息端点
- python - 尝试使用 drop 函数删除具有某些条件的行
- c# - VS 的 EditorConfig 命名在 VS 2017 中不起作用
- wordpress - 提交表单后保持我的引导模式打开