-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move: redis config 패키지 이동 * chore: PropertiesConfig 추가와 configuration-processor 의존성 추가 * chore: AWS 의존성 추가 * chore: Storage Config 생성 * chore: storage.yml 추가 * refactor: RedisProperties 적용 * style: spotless * refactor: properties record 적용
- Loading branch information
Showing
9 changed files
with
74 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/depromeet/infra/config/properties/PropertiesConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.depromeet.infra.config.properties; | ||
|
||
import com.depromeet.infra.config.redis.RedisProperties; | ||
import com.depromeet.infra.config.storage.StorageProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@EnableConfigurationProperties({StorageProperties.class, RedisProperties.class}) | ||
@Configuration | ||
public class PropertiesConfig {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/depromeet/infra/config/redis/RedisProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.depromeet.infra.config.redis; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "spring.data.redis") | ||
public record RedisProperties(String host, int port, String password) {} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/depromeet/infra/config/storage/StorageConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.depromeet.infra.config.storage; | ||
|
||
import com.amazonaws.auth.AWSCredentials; | ||
import com.amazonaws.auth.AWSStaticCredentialsProvider; | ||
import com.amazonaws.auth.BasicAWSCredentials; | ||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class StorageConfig { | ||
private final StorageProperties storageProperties; | ||
|
||
@Bean | ||
public AmazonS3 amazonS3() { | ||
AWSCredentials credentials = | ||
new BasicAWSCredentials( | ||
storageProperties.accessKey(), storageProperties.secretKey()); | ||
return AmazonS3ClientBuilder.standard() | ||
.withCredentials(new AWSStaticCredentialsProvider(credentials)) | ||
.withRegion(storageProperties.region()) | ||
.build(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/depromeet/infra/config/storage/StorageProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.depromeet.infra.config.storage; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "storage") | ||
public record StorageProperties(String accessKey, String secretKey, String region, String bucket) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
spring: | ||
config: | ||
activate: | ||
on-profile: "storage" | ||
storage: | ||
accessKey: ${STORAGE_ACCESS_KEY:} | ||
secretKey: ${STORAGE_SECRET_KEY:} | ||
region: ${STORAGE_REGION:} | ||
bucket: ${STORAGE_BUCKET:} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters