AWS S3로 이미지 업로드하는 기능을 실행했을 때 아래와 같은 에러 로그가 출력되었다.
💡 The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. (Service: Amazon S3; Status Code: 301; Error Code: PermanentRedirect; Request ID:) AWS Error Code: PermanentRedirect
AWS S3 Client 를 이용할 경우 Region 이 일치하지 않을 때 발생하는 에러.
application.yml에 ap-northeast-2로 잘 설정되어있음.
putObject에서 에러가나길래 버킷의 정책 설정에 putObject가 추가되어있는지 확인. 이상없음.
region이 us-west-2로 나옴. application.yml에 설정한 region을 못가져오는 이유는?
의존성 주입은 AmazonS3Client인데
config에서는 리턴타입이 AmazonS3로 되어있었던 것.
리턴타입을 AmazonS3Client로 바꾸고나니 에러가 해결되었다.