vscode에서 aws toolkit 설치
접속하고 싶은 service 우클릭, enable 클릭
컨테이너에서 우클릭하고 open terminal 클릭
no valid instances for this container가 뜨면 우선 컨테이너가 정상적으로 실행 중인지, 로그가 잘 뜨는지 등 확인 필요.
그리고 executecommand가 설정 됐는지 확인해야 함
aws ecs describe-tasks --cluster {클러스터명} --tasks {task id}
enalbeExecuteCommand가 false면
로그인하고 executecommand true로 수정하는 명령어를 사용해야 함. 실행 중인 task에는 적용되지 않으므로 설정을 했지만 task의 enableExecuteCommand가 false라면 재배포를 해서 새로운 task를 만들어줘야 함.
로그인
aws --region ap-northeast-2 ecr get-login-password | docker login --username AWS --password-stdin xxx.dkr.ecr.us-west-2.amazonaws.com
배포 방식이 rolling 인 경우
aws ecs update-service --cluster {ecs 클러스터명} --service {ecs 서비스명} --region {지역} --enable-execute-command --force-new-deployment
배포 방식이 blue/green 배포인 경우
aws ecs update-service \
--cluster {ecs 클러스터명} \
--service {ecs 서비스명} \
--enable-execute-command \
--region {지역}
출력의 맨 마지막에 enableExecuteCommand가 true여야 함.
task 확인, task id는 task arn의 맨 마지막 값임.
arn:aws:ecs:ap-northeast-2:xxx:task/{service name}/{여기에 있는 값이 task id}
aws ecs describe-tasks --cluster DEV-FYM-DJANGO --tasks {task id}
task의 enableExecuteCommand가 false면 task를 새로 생성해야 함.
검증
brew install jq
aws ecs describe-services \
--cluster clusterName \
--service serviceName \
--region region \
| jq -r '.[] | .[].enableExecuteCommand'
재배포되면 다시 컨테이너에서 우클릭하고 open terminal 클릭