amazon-web-services - AWS Elastic Beanstalk 和 Secret Manager
问题描述
有谁知道是否可以在弹性豆茎中将秘密值作为环境变量传递?显然,替代方案是在我们的代码库中使用 sdk,但我想先探索环境变量方法
干杯达米安
解决方案
根据@Ali 的回答,此时它不是内置的。但是,使用.ebextensions和 AWS cli相对容易。这是一个根据 MY_ENV 环境变量将机密提取到文件的示例。然后可以将此值设置为环境变量,但请记住环境变量是特定于 shell 的。您需要将它们传递给您正在启动的任何东西。
10-extract-htpasswd:
env:
MY_ENV:
"Fn::GetOptionSetting":
Namespace: "aws:elasticbeanstalk:application:environment"
OptionName: MY_ENV
command: |
aws secretsmanager get-secret-value --secret-id myproj/$MY_ENV/htpasswd --region=us-east-1 --query=SecretString --output text > /etc/nginx/.htpasswd
chmod o-rwx /etc/nginx/.htpasswd
chgrp nginx /etc/nginx/.htpasswd
这还需要向 EB 服务角色授予对密钥的 IAM 权限。即这样的政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "xxxxxxxxxx",
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "arn:aws:secretsmanager:us-east-1:xxxxxxxxxxxx:secret:myproj*"
}
]
}
推荐阅读
- python - 无法为数组分配内存,rdkit 转换为 numpy 数组错误
- java - Libgdx 冲突问题
- sql - 如何从 UNION 中的单个查询中获取 @@ROWCOUNT - 使用 RowCount 创建尾部记录
- flutter - Streambuilder 只触发一次
- json - Apache Airflow:气流 initdb 导致“ImportError:没有名为 json 的模块”
- html - 字体退化问题
- django - 如何使用 BeautifulSoup 搜索出现在另一个元素之前的元素?
- macos - 使用新泽西州 v110.78 的 sml 标准 ML 在 MACOS High Sierra 版本 10.13.6 编译时出错
- c# - 在组合框中选择时显示项目的特定部分
- fax - 通过 RingCentral API 发送传真