Skip to content

Commit

Permalink
Fix: dockerFile, github action 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mjttong committed Aug 27, 2024
1 parent 711c37b commit d6f6cea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ jobs:
## create application-prod.properties
- name: create application.yml
run: |
cd ./src/main
cd ./resources
mkdir -p ./src/main/resources
cd ./src/main/resources
touch ./application.yml
ls *
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml
- name: Build with Gradle
Expand Down
31 changes: 26 additions & 5 deletions src/main/java/acc/hotsix/file_share/global/config/S3Config.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
package acc.hotsix.file_share.global.config;

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.DefaultCredentialsProvider;
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.AP_NORTHEAST_2)
.credentialsProvider(DefaultCredentialsProvider.create())
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider())
.build();
}

// presignedURL 을 적용하기 위한 S3Presigner 객체 생성
@Bean
public S3Presigner s3Presigner() {
return S3Presigner.builder()
.region(Region.AP_NORTHEAST_2)
.credentialsProvider(DefaultCredentialsProvider.create())
.region(Region.of(region))
.credentialsProvider(awsCredentialsProvider())
.build();
}
}

0 comments on commit d6f6cea

Please sign in to comment.