简体   繁体   中英

Use spring-cloud-aws-autoconfigure without access key and secret key, but assume role?

We have a spring cloud function deployed on AWS lambda. How can we get spring-cloud-aws-autoconfigure to work without access key and secret key, assuming the keys set by the lambda execution role instead?

If we use the autoconfigure, it always throws:

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]

Thanks

Currently you need to provide custom credentials provider bean that assumes role in order to prevent Spring Cloud AWS to create the default credentials provider ( this bean specifically

You can take a look how to implement credentials provider that assumes role here . This PR will be merged in Spring Cloud AWS 2.3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM