Skip to content

Commit

Permalink
Fix: credetial을 IAM role을 통해 부여하는 방식으로 변화
Browse files Browse the repository at this point in the history
  • Loading branch information
mjttong committed Aug 27, 2024
1 parent c8cd747 commit c308293
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/main/java/acc/hotsix/file_share/global/config/S3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,20 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

@Configuration
public class S3Config {

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

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

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

// access, secret key 이용해 aws 자격증명 제공
@Bean
public AwsCredentialsProvider awsCredentialsProvider() {
AwsCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretKey);
return StaticCredentialsProvider.create(awsCredentials);
}

// s3서비스를 이용하기 위한 S3Client 객체 생성
@Bean
public S3Client s3Client() {
return S3Client.builder()
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider())
.build();
}

Expand All @@ -44,7 +25,6 @@ public S3Client s3Client() {
public S3Presigner s3Presigner() {
return S3Presigner.builder()
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider())
.build();
}
}

0 comments on commit c308293

Please sign in to comment.