自定义凭证提供程序插件

custom credential provider plugin

要检索凭据(aws_access_key、aws_secret_access_key、aws_session_token)以通过 cli 访问 AWS 服务,我们必须先调用自定义服务以获取我们的临时凭据。如果凭据已过期,我们需要检索新的凭据。

使用 boto 可以通过扩展 boto.provider.Provider 来编写自定义凭证提供程序。是否有类似的东西可以扩展 aws cli?

虽然没有记录,但我知道可以为 aws cli 编写插件。我可以利用此功能来实现我自己的凭据检索器吗?

您需要创建一个实现 CredentialProvider class in botocore.

的对象

创建后,您可以让 CLI 将其添加到凭证提供程序集中进行检查。

如果您想要这样的示例,AssumeRole 凭据提供程序在 CLI 中被编写为 "internal" 插件。您需要执行 something similar to this. You'll get the credential_provider component from the session and then inject yours into the chain. You might want to take a look at the default set of providers 并决定您的自定义凭据提供程序应放置在何处。