【问题标题】:How to Configure using STSAssumeRoleSessionCredentialsProvider in spring-cloud-stream-binder-kinesis如何在 spring-cloud-stream-binder-kinesis 中使用 STSAssumeRoleSessionCredentialsProvider 进行配置
【发布时间】:2020-09-22 18:46:53
【问题描述】:

我正在使用 spring-cloud-stream-binder-kinesis,版本:2.0.2.RELEASE。

我能够成功使用活页夹并使用 KinesisBinderConfiguration 中提到的默认 ContextCredentialsAutoConfiguration 在本地访问它。

现在我知道这种设置对我不起作用,因为, Kinesis 数据流位于 AWS 账户 1 中 该服务正在 AWS 账户 2 中运行 (我已经完成了假定角色的设置,以便帐户 2 可以使用假定角色访问帐户 1 中的流)

但是我不确定如何覆盖活页夹中的凭据以使用 STSAssumeRoleSessionCredentialsProvider

有人可以帮忙吗?

【问题讨论】:

    标签: java spring-boot spring-cloud-stream amazon-kinesis


    【解决方案1】:

    KinesisBinderConfiguration 完全基于 Spring Cloud AWS 的自动配置,它为我们提供了一个 ContextCredentialsAutoConfiguration 并在 credentialsProvider 名称下公开一个 AWSCredentialsProvider bean(如果尚不存在)。

    因此,您可能只需将 STSAssumeRoleSessionCredentialsProvider 作为配置类中的 bean 并为其指定 credentialsProvider bean 名称。

    【讨论】:

    • 谢谢!通过添加以下 bean 使其工作:@Bean @Primary public AWSCredentialsProvider awsCredentialsProvider() { return new STSAssumeRoleSessionCredentialsProvider.Builder(roleArn, roleSession).build(); }
    猜你喜欢
    • 2019-04-19
    • 2019-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多