Skip to content

Commit

Permalink
[feat] #72 s3 초기 세팅
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeesw committed Aug 24, 2024
1 parent 3ee0312 commit 19afc1f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ dependencies {
// jwt
implementation 'io.jsonwebtoken:jjwt:0.9.1'

//s3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

developmentOnly 'org.springframework.boot:spring-boot-devtools'

compileOnly 'org.projectlombok:lombok'
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/com/book/backend/global/s3/S3Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.book.backend.global.s3;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Value;
import com.amazonaws.services.s3.AmazonS3;

@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;

@Bean
public AmazonS3 s3Client() {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);

return AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion(region)
.build();
}
}
12 changes: 12 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@ jwt:
secretKey: ${JWT_SECRET}
accessTokenExpireTime: ${ACCESS_TOKEN_EXPIRE_TIME}
refreshTokenExpireTime: ${REFRESH_TOKEN_EXPIRE_TIME}

cloud:
aws:
s3:
bucket: ${AWS_S3_BUCKET_NAME}
credentials:
access-key: ${AWS_S3_BUCKET_ACCESS_KEY}
secret-key: ${AWS_S3_BUCKET_SECRET_KEY}
region:
static: ap-northeast-2 # 버킷 생성 지역
stack:
auto: false #??

0 comments on commit 19afc1f

Please sign in to comment.