在没有访问密钥和秘密密钥的情况下使用spring-cloud-aws-autoconfigure,但要扮演角色?

时间:2020-07-09 18:39:54

标签: spring amazon-web-services cloud spring-cloud spring-cloud-aws

我们在AWS lambda上部署了spring cloud功能。假设使用lambda执行角色设置的密钥,如何在没有访问密钥和秘密密钥的情况下使spring-cloud-aws-autoconfigure正常工作?

如果使用自动配置,它将始终抛出:

org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name
'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration':
Unsatisfied dependency expressed through constructor parameter 0;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'tarodb': Invocation of init method failed;
nested exception is com.amazonaws.SdkClientException: Unable to load
AWS credentials from any provider in the chain:
[com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@7e990ed7:
Unable to load credentials from service endpoint,
com.amazonaws.auth.profile.ProfileCredentialsProvider@821330f: profile
file cannot be null]

谢谢

1 个答案:

答案 0 :(得分:0)

当前,您需要提供承担角色的自定义凭据提供程序bean,以防止Spring Cloud AWS创建默认凭据提供程序(this bean specifically

您可以看看如何实现承担角色here的凭据提供程序。该PR将在Spring Cloud AWS 2.3中合并。