-
Notifications
You must be signed in to change notification settings - Fork 1
[Fix] AWS SDK v2 마이그레이션 (#548) #550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates AWS SDK v1 usage to AWS SDK v2 to resolve Jackson version conflicts and remove deprecated dependency usage. Key changes include:
- Replacing AWS SDK v1 beans in AwsConfig.java with S3Client and S3Presigner beans from AWS SDK v2.
- Updating S3Service.java to use AWS SDK v2 APIs for generating pre-signed URLs and deleting S3 objects.
- Refactoring JwtTokenService.java to use LocalDateTime-based conversions for JWT token issuance.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/java/org/sopt/app/common/config/AwsConfig.java | Migrated from AWS SDK v1 to AWS SDK v2 bean creation and updated variable naming. |
| src/main/java/org/sopt/app/application/s3/S3Service.java | Replaced legacy S3 API calls with SDK v2 methods and updated pre-signed URL and deletion logic. |
| src/main/java/org/sopt/app/application/auth/JwtTokenService.java | Updated date conversion for JWT tokens using LocalDateTime and ZoneId. |
Comments suppressed due to low confidence (1)
src/main/java/org/sopt/app/application/auth/JwtTokenService.java:50
- [nitpick] The variable name 'nowDate1PlusDays' could be renamed to 'expirationDate' to improve clarity about its purpose.
val nowDate1PlusDays = Date.from(now.plusDays(1).atZone(ZoneId.systemDefault()).toInstant());
| // SDK v2 예외 처리 | ||
| LoggerFactory.getLogger(S3Service.class).error("Error deleting S3 object {}: {}", objectKey, e.awsErrorDetails().errorMessage()); | ||
| } catch (SdkException e) { | ||
| LoggerFactory.getLogger(S3Service.class).error("AWS SDK error deleting S3 object {}: {}", objectKey, e.getMessage()); |
Copilot
AI
Apr 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the deleteFile method, errors caught from SdkException and S3Exception are only logged without propagating the failure. Consider rethrowing the exception or handling it appropriately if deletion failure must be communicated to callers.
| // SDK v2 예외 처리 | |
| LoggerFactory.getLogger(S3Service.class).error("Error deleting S3 object {}: {}", objectKey, e.awsErrorDetails().errorMessage()); | |
| } catch (SdkException e) { | |
| LoggerFactory.getLogger(S3Service.class).error("AWS SDK error deleting S3 object {}: {}", objectKey, e.getMessage()); | |
| LoggerFactory.getLogger(S3Service.class).error("Error deleting S3 object {}: {}", objectKey, e.awsErrorDetails().errorMessage()); | |
| throw new RuntimeException("Failed to delete S3 object: " + objectKey, e); | |
| } catch (SdkException e) { | |
| LoggerFactory.getLogger(S3Service.class).error("AWS SDK error deleting S3 object {}: {}", objectKey, e.getMessage()); | |
| throw new RuntimeException("AWS SDK error deleting S3 object: " + objectKey, e); |
…ecentPosts에서 config value dto에 넣도록 수정
Related issue 🛠
Work Description ✏️
Situation
기존에
spring-cloud-starter-aws(AWS SDK v1 기반)를 사용하고, AWS 자격 증명을application.yml에서@Value로 주입받아 설정하는 방식을 사용하고 있었어요.이 상황에서 자동 AWS 자격 증명 메커니즘을 사용하도록 변경하니, 오래된
spring-cloud-starter-aws가 의존하는 Jackson 라이브러리 버전과, 다른 최신 라이브러리(Spring Boot, Feign 등)가 의존하는 Jackson 버전이 충돌하여NoSuchFieldError(Jackson 필드 없음) 오류가 발생했어요.Action
다음과 같이 개선 작업을 진행했어요.
AWS SDK v2 마이그레이션:
spring-cloud-starter-aws의존성을 제거했습니다.build.gradle에 AWS SDK v2 BOM 및 필요한s3모듈 의존성을 추가하여 최신 SDK를 사용하도록 변경했습니다.관련 코드 수정:
AwsConfig.java를 AWS SDK v2의S3Client,S3Presigner빈을 생성하도록 수정했습니다.S3Service.java에서 AWS SDK v1 API 대신 SDK v2 API (S3Client,S3Presigner사용)를 사용하도록 Pre-signed URL 생성 및 객체 삭제 로직 등을 수정했습니다.작업 내용은 다음과 같아요.
build.gradle의존성 수정 (SDK v1 제거, SDK v2 BOM 및 s3 모듈 추가)AwsConfig.java수정 (SDK v2 사용 및 명시적 자격 증명 제거)S3Service.java수정Trouble Shooting ⚽️
Related ScreenShot 📷
Uncompleted Tasks 😅
To Reviewers 📢