2

I want to connect AWS with using spring cloud.

This is a piece of myconfig class :

@EnableSqs
public class AwsCloudConfig {

    @Value("${cloud.aws.region}")
    private String region;

    @Value("${cloud.aws.profile}")
    private String profile;

    @Value("${cloud.aws.roleArn}")
    private String role;

    @Value("${cloud.aws.user}")
    private String userKey;

    @Value("${cloud.aws.credentials.accessKey}")
    private String accessKey;

    @Value("${cloud.aws.credentials.secretKey}")
    private String secretKey;

    //... 

}

Normally Spring inject these properties from my properties file without any problem.

But it doesn't inject them whem I add this dependency :

org.springframework.cloud:spring-cloud-starter-aws-messaging

Why this dependency effects springs property injection functionality? is there any idea?

sam
  • 1,073
  • 4
  • 13
  • 27

1 Answers1

0

can you try like this ?

 @Bean
public AmazonS3 amazonS3(@Value("${cloud.aws.credentials.accessKey}") String accessKey,
                         @Value("${cloud.aws.credentials.secretKey}") String secretKey,
                         @Value("${cloud.aws.region}") String region) {
    AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
    AmazonS3 amazonS3ClientBuilder= AmazonS3ClientBuilder.standard()
            .withRegion(region)
            .withCredentials(new AWSStaticCredentialsProvider(credentials))
            .build();
    return amazonS3ClientBuilder;
}
Rhmn61
  • 200
  • 2
  • 12