Skip to content

Commit 72ef837

Browse files
committed
[FEAT] 무중단 배포 시 s3 오류 잡기 #1
1 parent 360711d commit 72ef837

9 files changed

Lines changed: 35 additions & 202 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@ jobs:
2828
- name: Grant execute permission for gradlew
2929
run: chmod +x ./gradlew
3030

31-
# - name: Set Yaml
32-
# uses: microsoft/variable-substitution@v1
33-
# with:
34-
# files: ./src/main/resources/application-real.yml
35-
# env:
36-
# spring.datasource.url: ${{ secrets.RDS_HOST }}
37-
# spring.datasource.username: ${{ secrets.RDS_USERNAME }}
38-
# spring.datasource.password: ${{ secrets.RDS_PASSWORD }}
39-
# jwt.secret: ${{ secrets.JWT_SECRET }}
40-
# cloud.aws.credentials.accessKey: ${{secrets.AWS_S3_ACCESS_KEY}}
41-
# cloud.aws.credentials.secretKey: ${{secrets.AWS_S3_SECRET_KEY}}
42-
# cloud.aws.s3.region: ${{secrets.AWS_REGION}}
43-
# cloud.aws.s3.bucket: ${{secrets.AWS_S3_BUCKET_NAME}}
4431
- name: Set Yaml-1
4532
uses: microsoft/variable-substitution@v1
4633
with:
@@ -113,28 +100,3 @@ jobs:
113100
- name: Code Deploy
114101
run: aws deploy create-deployment --application-name dplus-deploy --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name develop --s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip
115102

116-
117-
118-
119-
120-
# - name: Generate deployment package
121-
# run: |
122-
# mkdir -p deploy cp build/libs/*.jar deploy/application.jar # 빌드 완료 시 jar 파일명을 application.jar로 변경
123-
# cp Procfile deploy/Procfile
124-
# cp -r .ebextensions deploy/.ebextensions
125-
# cp -r .platform deploy/.platform
126-
# cd deploy && zip -r deploy.zip . # Procfile, .ebextensions, .platform 포함하여 zip 생성
127-
128-
# # Beanstalk Deploy 플러그인 사용
129-
# - name: Beanstalk Deploy
130-
# uses: einaregilsson/beanstalk-deploy@v14
131-
# with:
132-
# aws_access_key: ${{ secrets.AWS_EB_ACCESS_KEY }} # github secrets로 등록한 값 사용
133-
# aws_secret_key: ${{ secrets.AWS_EB_SECRET_KEY }} # github secrets로 등록한 값 사용
134-
# application_name: dplus-beanstalk # EB application 이름
135-
# environment_name: Dplusbeanstalk-env # EB environment 이름
136-
# version_label: github-action-${{steps.current-time.outputs.formattedTime}} # 배포 버전은 타임스탬프를 이용하여 구분
137-
# region: ap-northeast-2
138-
# deployment_package: deploy/deploy.zip
139-
# wait_for_environment_recovery: 300 # default wait time은 30초이며, 필자의 EB가 느려서 180초로 지정했습니다(지정 안하면 간혹 timeout 발생).
140-
#

‎appspec.yml‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,3 @@ hooks:
3030
# timeout: 60
3131
# runas: ec2-user
3232

33-
#hooks:
34-
# ApplicationStart:
35-
# - location: run_new_was.sh
36-
# timeout: 180
37-
# runas: ec2-user
38-
#
39-
# - location: health_check.sh
40-
# timeout: 180
41-
# runas: ec2-user
42-
#
43-
# - location: switch_was.sh
44-
# timeout: 180
45-
# runas: ec2-user

‎scripts/deploy.sh‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎scripts/health_check.sh‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎scripts/run_new_was.sh‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎scripts/switch_was.sh‎

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
//package TeamDPlus.code.config.amazons3;
2-
//
3-
//
4-
//import com.amazonaws.auth.AWSStaticCredentialsProvider;
5-
//import com.amazonaws.auth.BasicAWSCredentials;
6-
//import com.amazonaws.services.s3.AmazonS3Client;
7-
//import com.amazonaws.services.s3.AmazonS3ClientBuilder;
8-
//import org.springframework.beans.factory.annotation.Value;
9-
//import org.springframework.context.annotation.Bean;
10-
//import org.springframework.context.annotation.Configuration;
11-
//
12-
//@Configuration
13-
//public class AmazonConfig {
14-
//
15-
//
16-
// @Value("${cloud.aws.credentials.access-key}")
17-
// private String accessKey;
18-
//
19-
// @Value("${cloud.aws.credentials.secret-key}")
20-
// private String secretKey;
21-
//
22-
// @Value("${cloud.aws.region.static}")
23-
// private String region;
24-
//
25-
// @Bean
26-
// public AmazonS3Client amazonS3Client() {
27-
// BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secretKey);
28-
// return (AmazonS3Client) AmazonS3ClientBuilder.standard()
29-
// .withRegion(region)
30-
// .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
31-
// .build();
32-
// }
33-
//}
1+
package TeamDPlus.code.config.amazons3;
2+
3+
4+
import com.amazonaws.auth.AWSStaticCredentialsProvider;
5+
import com.amazonaws.auth.BasicAWSCredentials;
6+
import com.amazonaws.services.s3.AmazonS3Client;
7+
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
8+
import org.springframework.beans.factory.annotation.Value;
9+
import org.springframework.context.annotation.Bean;
10+
import org.springframework.context.annotation.Configuration;
11+
12+
@Configuration
13+
public class AmazonConfig {
14+
15+
16+
@Value("${cloud.aws.credentials.access-key}")
17+
private String accessKey;
18+
19+
@Value("${cloud.aws.credentials.secret-key}")
20+
private String secretKey;
21+
22+
@Value("${cloud.aws.region}")
23+
private String region;
24+
25+
@Bean
26+
public AmazonS3Client amazonS3Client() {
27+
BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secretKey);
28+
return (AmazonS3Client) AmazonS3ClientBuilder.standard()
29+
.withRegion(region)
30+
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
31+
.build();
32+
}
33+
}

‎src/main/resources/application-real1.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ cloud:
2727
aws:
2828
s3:
2929
bucket: ${aws.s3.bucketname}
30-
region:
31-
static: ap-northeast-2
30+
region: ${aws.s3.region}
3231
stack:
3332
auto: false
3433

‎src/main/resources/application-real2.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ cloud:
2727
aws:
2828
s3:
2929
bucket: ${aws.s3.bucketname}
30-
region:
31-
static: ap-northeast-2
30+
region: ${cloud.aws.s3.region}
3231
stack:
3332
auto: false
3433

0 commit comments

Comments
 (0)