0

我目前正在尝试使用 SSM 作为密钥提供者来设置一个 confd POC,我们目前在 AWS 上有一个帐户,它是根帐户和多个角色来分隔环境。

目前我的 AWS 配置看起来像这样

[default]
region=eu-west-1
output=json
role_arn=arn:aws:iam::*:role/OrganizationAccountAccessRole

给定命令,这对我来说很好

aws ssm get-parameters --names /eric

把我为这个 poc 创建的密钥还给我

PARAMETERS  arn:aws:ssm:eu-west-1:*:parameter/eric * /eric  String  test    1

对于 confd 虽然它没有

confd -onetime -backend ssm --log-level debug

2019-04-07T18:25:08Z 3ce95f057568 confd[359]: DEBUG Processing key=/eric
2019-04-07T18:25:08Z 3ce95f057568 confd[359]: DEBUG Got the following map from store: map[]
2019-04-07T18:25:08Z 3ce95f057568 confd[359]: DEBUG Using source template /etc/confd/templates/myconfig.conf.tmpl
2019-04-07T18:25:08Z 3ce95f057568 confd[359]: DEBUG Compiling source template /etc/confd/templates/myconfig.conf.tmpl
2019-04-07T18:25:08Z 3ce95f057568 confd[359]: ERROR template: myconfig.conf.tmpl:2:17: executing "myconfig.conf.tmpl" at <getv "/eric">: error calling getv: key does not exist: /eric
2019-04-07T18:25:08Z 3ce95f057568 confd[359]: FATAL template: myconfig.conf.tmpl:2:17: executing "myconfig.conf.tmpl" at <getv "/eric">: error calling getv: key does not exist: /eric

我做了一个简短的测试,并在 root 帐户而不是角色帐户中创建了密钥 /eric,之后它按我的预期工作,这让我想知道,是否有任何隐藏的配置 confd 使其“使用”角色? 因为目前它似乎没有考虑到这个角色。

我的 confd 模板看起来像

[template]
src = "myconfig.conf.tmpl"
dest = "/tmp/myconfig.conf"
keys = [
    "/eric"
]

我的 confd 配置看起来像

database_url = {{getv "/eric"}}

有人可以就这个具体问题给我任何指导吗?

4

1 回答 1

0

好的,我发现了问题,我的 AWS 配置已被完全忽略,在查看了该项目当前打开的拉取请求后,我找到了这个。

https://github.com/kelseyhightower/confd/pull/736,作者提到

除非导出了环境变量 AWS_SDK_LOAD_CONFIG,否则现有会话创建会忽略 AWS 配置选项。SharedConfigState 选项消除了这种需要。

所以是的,将 var AWS_SDK_LOAD_CONFIG 设置为 true 做到了这一点,我假设当这个 pr 得到合并时,这个“解决方法”将是没有必要的。

于 2019-04-08T11:45:38.197 回答