Codedeploy + Github actions 로 CI/CD를 구축하면서 엄청나게 많은 시도와 많은 에러메세지들을 만났었는데,
시도하면서 만난 에러메세지들과 해결방법들을 정리해두려고 한다.
(Github actions에서 겪은 문제들은 따로 올릴 예정!)
Error 로그 확인방법
1. 먼저 Codedeploy의 경우 AWS codedeploy에서 해당 배포를 클릭하면 에러메세지를 확인할 수 있다.
codedeploy설정과 관련된 에러라면 대부분 여기 빨간박스에 에러메세지가 뜬다.
2. codedeploy설정이 아닌, 배포스크립트를 수행하던 중 오류가 발생했다면,
하단으로 스크롤하여 View events를 클릭하면, 더욱 자세한 오류메세지를 보여준다.
View events 클릭
여기서 하단의 ScriptFailed를 클릭하면 더더욱 자세한 로그를 볼 수 있다.
실제로 EC2에서 배포스크립트를 실행하다가 생긴 에러를 그대로 보여준다.
2. EC2에서 codedeploy 관련 log를 확인하고 싶은 경우
$ tail -F /var/log/aws/codedeploy-agent/codedeploy-agent.log
내가겪은에러들
1. EC2 Not found
The deployment failed because no instances were found for your deployment group. Check your deployment group settings to make sure the tags for your Amazon EC2 instances or Auto Scaling groups correctly identify the instances you want to deploy to, and then try again.
-> 조건에 일치하는 EC2가 없을 때 나오는 에러
배포그룹 생성시 codedeploy를 이용할 인스턴스를 Key-Value로 등록하게된다.
나는 주로 Name키를 이용하여 EC2이름으로 식별하곤했다.
이 부분을 다시한번 확인해서 codedeploy를 사용할 인스턴스를 명시해주면 된다.
2. 배포스크립트 실행 에러
The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.
이 메세지는 주로 배포스크립트를 실행하던 중 문제가 생겼을 때 나오는 메세지이다.
상세한 에러로그 확인을 위해서는 이 글 상단에 작성한 Error로그 확인방법들을 시도하면된다.
3. Access Denied
Access Denied
Access Denied의 경우 배포zip파일을 업로드한 S3버킷에 접근할 수 없는 경우에 뜬다.
나같은 경우엔 github actions에서 codedeploy로 S3버킷의 파일을 EC2로 업로드하는 과정에서 버킷이름 오타가 있었다!
버킷이름에 오타가 없다면, Codedeploy설정과정에서 S3관련된 권한 부분을 잘 적용했는지 체크해보자.
/.github/workflows/deploy.yml
...
- name: Deploy with AWS codedeploy
run: aws deploy create-deployment
-application-name {application_name}
--deployment-config-name CodeDeployDefault.OneAtATime
--deployment-group-name {deploy_group}
--s3-location bucket={bucket_name},bundleType=zip,key={file_name}
이 부분에서 bucket_name을 확인하기
큰 오류들은 이정도였고, github actions, 배포스크립트 관련 에러도 있었다...😇
그건 다음에 또 정리해야지~