implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
cloud.aws.credentials.accessKey=S3 접근키
cloud.aws.credentials.secretKey=S3 시크릿키
logging.level.com.amazonaws.util.EC2MetadataUtils=error
cloud.aws.s3.bucket=s3저장 장소
cloud.aws.region.static=s3지역 저는 ap-northeast-2로 진행
cloud.aws.stack.auto=false
@RequiredArgsConstructor
@Configuration
public class AwsS3Config {
//프로퍼티스의 어세스키
@Value("${cloud.aws.credentials.accessKey}")
private String accessKey;
//프로퍼티스의 시크릿키
@Value("${cloud.aws.credentials.secret-key}")
private String secretKey;
//프로퍼티스의 버킷 지역
@Value("${cloud.aws.region.static}")
private String region;
//빈설정
@Bean
public AmazonS3Client amazonS3Client() {
BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secretKey);
return (AmazonS3Client) AmazonS3ClientBuilder.standard()
.withRegion(region)
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.build();
}
}
기본 설정은 끝났다.