看起来 Vault 不使用AWS_CONFIG_FILE
env 变量进行配置。Vault 服务器作为 systemd 服务运行。中的环境文件/etc/systemd/system/custom.env
用于启用 KMS 密封并显式指向/.aws/config
具有 IAM 角色设置的自定义 aws 配置位置。
/etc/systemd/system/custom.env
VAULT_AWSKMS_SEAL_KEY_ID=xxxxxxx
VAULT_SEAL_TYPE=awskms
AWS_CONFIG_FILE=/.aws/config
AWS_PROFILE=vault-admin
AWS_DEFAULT_REGION=us-east-1
/.aws/config
[default]
aws_access_key_id = xxxx
aws_secret_access_key = xxxx
region = us-east-1
[profile vault-admin]
role_arn = xxxx
source_profile = default
但是,Vault 无法启动并抱怨缺少凭据:
Error parsing Seal configuration: error fetching AWS KMS wrapping key information: NoCredentialProviders: no valid providers in in chain. Deprecated.
解决此问题的唯一方法是在custom.env
文件中硬编码具有 KMS 权限的用户的凭据,我想避免这种情况,因为它会失去 IAM 角色的好处。
根据文档:
Vault uses the official AWS SDK and will use the specified credentials, environment credentials, shared file credentials, or IAM role/ECS task credentials in that order, if the above AWS specific values are not provided.
所以我很困惑为什么 Vault 忽略了AWS_CONFIG_FILE
env。
在启动服务之前,我还取消了其他全球 AWS 环境。谁能找出问题所在?
vault.service
文件的一部分
[Service]
User=vault
Group=vault
EnvironmentFile=/etc/systemd/system/custom.env
ExecStart=/usr/local/bin/vault server -config=/etc/vault.d
ExecReload=/bin/kill --signal HUP $MAINPID
Restart=on-failure
StartLimitInterval=200s
StartLimitBurst=5
RestartSec=30