skill/Linux

AWS 서버 Jenkins pipeline 연결 시, codedeploy-agent 설치 및 IAM 연동

have a nice day :D 2022. 6. 16. 11:14
반응형

[CodeDeploy error] : ApplicationStop : [error] CodeDeploy agent was not able to receive the lifecycle event. Check the CodeDeploy agent logs on your host and make sure the agent is running and can connect to the CodeDeploy server.

+ 배포되는 서버에 CodeDeploy 에이전트가 실행 중인 지 확인

$ sudo service codedeploy-agent status

(비정상) Redirecting to /bin/systemctl status codedeploy-agent.service

(정상) The AWS CodeDeploy agent is running as PID 1755

+ codedeploy-agent 실행

$sudo service codedeploy-agent start

 

+ 실행 안될 때 설치 (참고:https://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/codedeploy-agent-operations-install-ubuntu.html)

$sudo yum update

$sudo yum install ruby

$wget https://aws-codedeploy-ap-northeast-2.s3.ap-northeast-2.amazonaws.com/latest/install

$chmod +x ./install

$sudo ./install auto

 

+ codedeploy 서버 재확인

$ sudo service codedeploy-agent status

[CodeDeploy error] : 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.

서버 로그 확인 : $/var/log/aws/codedeploy-agent

로그 정보 : Missing credentials - please check if this instance was started with an IAM instance profile

(IAM가 실행 전 CodeDeploy가 먼저 실행 되서 난 오류 라고 하여.. 재 시작 해봄)

$sudo service codedeploy-agent restart

(보통은 된다던데.. 내껀 왜 안될까)

(aws 인스턴스 화면 으로 이동)

인스턴스 > 보안 > IAM역할 확인 (없을 시) 작업 > 보안 > IAM역할 수정에 추가.

(하아.. 인스턴스에 IAM 역할 연동 해 주고, codedeploy-agent 재시작)

$sudo service codedeploy-agent restart

반응형