AWS ElasticBeanstalk 과 GitHub Action 을 이용한 CI/CD 구축 과정에서 일어난 문제 해결 과정
📍문제 상황📍
GitHub Action 에서의 배포 빌드는 성공이지만, AWS EB 에 프로젝트가 성공적으로 배포되지 않음
아예 안올라오는 것이 아니라, 같이 배포했던 NGINX 서버만 올라온 후, 502 Bad Gateway 오류 발생
로드 밸런서에서의 통신이 불가해 배포가 시도되었던 인스턴스 서버가 종료됨 (배포 안됨)
0. AWS ElasticBeanstalk 로그 다운
1. NGINX 에러 로그 확인 (nginx/error.log)
[error] 2737#2737: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.2.167, server: , request: "GET /health HTTP/1.1", upstream: "http://127.0.0.1:8080/health", host: "10.0.1.21"
➡️ AWS EB 생성 시 설정했던 헬스 체크용 경로로의 통신이 spring security 설정으로 막혔다고 생각해 설정 변경
@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
public class SecurityConfig{
...
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
//접근 권한 설정
.authorizeHttpRequests((authorizeRequests) ->
authorizeRequests
.requestMatchers("/", "/health").permitAll()
...
)
...
return http.build();
}
}
해결 안됨 !
2. SpringBoot 로그 확인 (messages)
ERROR 6902 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
Caused by: java.lang.IllegalStateException: Failed to introspect Class [umc.IRECIPE_Server.config.SecurityConfig] from ClassLoader [org.springframework.boot.loader.launch.LaunchedClassLoader@30f39991]
Caused by: java.lang.NoClassDefFoundError: org/springframework/security/config/annotation/web/builders/WebSecurity
Caused by: java.lang.ClassNotFoundException: org.springframework.security.config.annotation.web.builders.WebSecurity
➡️ Spring Security 추가 시 사용 가능한 어노테이션인 WebSecurity 를 인식하지 못해 build.gradle 설정 변경
...
dependencies {
...
// spring security
// compileOnly → implementation
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'
}
아직 해결 안됨 ! 다른 에러 로그 발생
3. SpringBoot 로그 확인 (messages)
WARN EC2RoleProvider Failed to connect to Systems Manager with instance profile role credentials. Err: retrieved credentials failed to report to ssm. RequestId: b7238eca-3c78-4f8b-91f0-90af838e3035
Error: AccessDeniedException: User: arn:aws:sts::계정ID:assumed-role/aws-elasticbeanstalk-ec2-role2/i-08a2b8c4a299199dd is not authorized to perform: ssm:UpdateInstanceInformation on resource: arn:aws:ec2:ap-northeast-2:계정ID:instance/i-08a2b8c4a299199dd because no identity-based policy allows the ssm:UpdateInstanceInformation action
ERROR EC2RoleProvider Failed to connect to Systems Manager with SSM role credentials. error calling RequestManagedInstanceRoleToken: AccessDeniedException: Systems Manager's instance management role is not configured for account: 계정ID
➡️ AWS EB 생성 시 설정해주었던 EC2 사용자 권한 부족 문제로 IAM 에서 권한 추가
드디어 해결 !!
😭 흑흑..
처음에 aws 에서 로그는 받아왔는데 계속 헬스 체크 통신이 문제라고 생각해 nginx 로그만 봤다..
springboot 서버가 아예 올라오지 않아서 로그가 없을 것이라고 생각했는데
messages 파일이 springboot 로그 파일일줄은 몰랐당..
로그 파일만 일찍 찾았어도 덜 고생했을텐데 !!!
암튼
다행이다,, ._.
'Spring > [P] AI 챗봇 기반 맞춤형 레시피 서비스' 카테고리의 다른 글
프로젝트 회고 - IRECIPE (1) | 2024.03.18 |
---|---|
[AWS ElasticBeanstalk/GitHub Action] CI/CD 구축 (3) EB 생성하기 (0) | 2024.03.14 |
[AWS ElasticBeanstalk/GitHub Action] CI/CD 구축 (2) GitHub Action Secrets 등록하기 (0) | 2024.03.13 |
[AWS ElasticBeanstalk/GitHub Action] CI/CD 구축 (1) 배포 스크립트 작성하기 (0) | 2024.03.12 |
[SpringBoot/Querydsl] QnA 대댓글 (4) 삭제 (0) | 2024.03.11 |