New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3 에 파일을 업로드 하기 위해, 의존성과 configuration 설정을 추가하라 #47
base: develop
Are you sure you want to change the base?
S3 에 파일을 업로드 하기 위해, 의존성과 configuration 설정을 추가하라 #47
Conversation
region: | ||
static: ap-northeast-2 | ||
credentials: | ||
access-key: AKIAYXA537A74IOP4V27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
access-key
, secre-key
를 github에 올리면 유출 위험이 있습니다.
application-private.yml
파일을 만들어서 application.yml
파일에 include 하는 방법으로 수정을 제안드립니다.
그리고 application-private.yml 파일은 github ignore 에서 제외 되어야하고요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아하, 여기 있군요...
아래처럼 되어있네요.
adapter-client-api 에는 @SpringBootApplication 을 가진 클래스가 없는데데 추가해도 되나요?
@SpringBootApplication
public class Application {
public static final String APPLICATION_LOCATIONS = "spring.config.location="
+ "classpath:application.yml,"
+ "classpath:aws.yml";
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class)
.properties(APPLICATION_LOCATIONS)
.run(args);
}
}```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adapters/web/adapter-client-api layer
에는 @SpringBootApplication
애노테이션 추가하면 안됩니다.
@SpringBootApplication
는 applications layer 에만 추가되어야합니다.
@@ -5,6 +5,7 @@ dependencies { | |||
implementation project(':domain') | |||
implementation project(':common') | |||
|
|||
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root/build.gradle
의 subprojects 안에 dependencyManagement안에 아래와 같이 추가해서
spring cloud stater 와 연관된 의존성들을 관리하는하는게 어떨지 제안드립니다.
ext {
springBootVersion = "2.3.4.RELEASE"
springCloudVersion = "Hoxton.SR11"
mockitoVersion = "3.4.0"
lombokVersion = "1.18.12"
}
...
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adapter-client-api
layer 에서 s3 를 언제 사용해야하나요???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래와 같이 현재 작업 중입니다.
(익숙한 MVC 구조로 먼저 작업하고 현재 아키텍처로 바꾸고 있음)
S3 로 업로드하는 Component 를 하나 만들고, Component 를 Service 에서 가져다 쓰는 구조입니다.
@Component
public class UploadImageS3 {
private final AmazonS3 amazonS3;
@Value("${aws.s3.image.bucket}")
private String bucket;
public ... upload() {}
}
@Service
public class ImageManagerService {
private final UploadImageS3 uploadImageS3;
public ... Upload() {
uploadImageS3.upload();
}
}
로컬 또는 테스트 환경에서는 access-key, secreat-key 를 사용하나 보안상 개발 또는 스테이지, 운영에서는 IamRole 인증을 사용하는게 좋을거같습니다. 용진님 생각은 어떠신가요? |
aws key를 삭제하는 커밋을 올린다음 머지가 될 경우 github에 영원히 기록이 남게됩니다. key 와 관련된 커밋 자체를 삭제해야합니다.
|
개요
작업 내용
참고 사항
출처: https://aws.amazon.com/ko/s3/pricing/
{ "Version": "2012-10-17", "Id": "Policy1622876424748", "Statement": [ { "Sid": "Stmt1622876421024", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::{bucket명}/*" } ] }