1

For spring boot 2.7.9

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>2.7.9</version>
   <relativePath /> <!-- lookup parent from repository -->
</parent>

These spring cloud dependencies

<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-context</artifactId>
    <version>2.4.2</version>
</dependency>
<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-autoconfigure</artifactId>
    <version>2.4.2</version>
</dependency>
<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-starter-aws-secrets-manager-config</artifactId>
    <version>2.4.2</version>
</dependency>

Properties entry

cloud.aws.region.static=us-east-2
cloud.aws.region.auto=false
cloud.aws.stack.auto=false

Server boots without any problem

For spring boot 3.0.2

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>3.0.2</version>
   <relativePath />
</parent>
<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-context</artifactId>
    <version>2.4.4</version>
</dependency>
<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-autoconfigure</artifactId>
    <version>2.4.4</version>
</dependency>
<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-starter-aws-secrets-manager-config</artifactId>
    <version>2.4.4</version>
</dependency>

Server stop with error

Field amazonS3Client in com.test.S3BucketStorageServiceImpl required a bean of type 'com.amazonaws.services.s3.AmazonS3' that could not be found. The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true) 
Action: Consider defining a bean of type 'com.amazonaws.services.s3.AmazonS3' in your configuration.

My Question: is the property file key names got changed ?

Dickens A S
  • 3,824
  • 2
  • 22
  • 45
  • Does this answer your question? [Which Spring Cloud AWS version should be used with Spring Boot 3?](https://stackoverflow.com/questions/74852003/which-spring-cloud-aws-version-should-be-used-with-spring-boot-3) – Tomaz Fernandes Mar 27 '23 at 21:29
  • no, it does not – Dickens A S Mar 28 '23 at 10:42
  • @DickensAS were you able to find an answer to your problem? I found a migration guide https://docs.awspring.io/spring-cloud-aws/docs/3.0.1/reference/html/index.html#migration-from-2-x-to-3-x . Even after checking this, I am facing the same problem. – Halley May 25 '23 at 02:51
  • @Halley I have provided the answer, check the same from your side and and confirm, we can close this is – Dickens A S May 25 '23 at 08:46

2 Answers2

0

Automatic configuration not working, Therefore I have to manually create a Bean

import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class MyS3Config {
    @Bean
    public AmazonS3 getS3Client() {
        return AmazonS3ClientBuilder.defaultClient();
    }
}

this solves the problem

Dickens A S
  • 3,824
  • 2
  • 22
  • 45
0

As Spring Cloud 3.0 provides good modularity and you have to include the specific AWS service for the autoconfigure to work:

Reference: https://docs.awspring.io/spring-cloud-aws/docs/3.0.0/reference/html/index.html

says:

Thanks to Spring Cloud AWS modularity you can include only dependencies relevant to the particular AWS service you want to integrate with.

So for spring-boot to autoconfigure the s3 client, you have to include:

<dependency>
    <groupId>io.awspring.cloud</groupId>
    <artifactId>spring-cloud-aws-starter-s3</artifactId>
</dependency>