ECS Exec 도입

hyuckhoon.ko·2023년 6월 8일
0

TIL

목록 보기
48/69

1. ecs service exec 활성화하기

aws ecs update-service \
  --cluster 클러스터명 \
  --service 서비스명 \
  --enable-execute-command

2. ecs force deploy

3. Session Manager 플러그인 설치

mac

https://docs.aws.amazon.com/ko_kr/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html#install-plugin-macos

4. 태스크 확인

aws ecs describe-tasks \
    --cluster cluster-name \
    --tasks task-id

5. aws cli로 exec 진행

aws ecs execute-command --cluster 클러스터명 \
--task 태스크명 \
--container 컨테이너명 \
--interactive \
--command "/bin/sh"

6. 에러 모음

1)

An error occurred (InvalidParameterException) when calling the ExecuteCommand operation: The execute command failed because execute command was not enabled when the task was run or the execute command agent isn’t running. Wait and try again or run a new task with execute command enabled and try again.

            ],
            "executeCommand": {
                "enable": true
            },

taskdef.json에 위 json 내용 추가

2)

An error occurred (TargetNotConnectedException) when calling the ExecuteCommand operation: The execute command failed due to an internal error. Try again later.

아래 정책을 ecsTaskExecutionRole에 추가한다.
그리고 반드시 task를 업데이트해야 한다.
(ECS의 서비스를 강제로 배포진행시킨다.)

{
   "Version": "2012-10-17",
   "Statement": [
       {
       "Effect": "Allow",
       "Action": [
            "ssmmessages:CreateControlChannel",
            "ssmmessages:CreateDataChannel",
            "ssmmessages:OpenControlChannel",
            "ssmmessages:OpenDataChannel"
       ],
      "Resource": "*"
      }
   ]
}

6. 결과

7. 참고자료

https://docs.aws.amazon.com/ko_kr/AmazonECS/latest/developerguide/ecs-exec.html

0개의 댓글

관련 채용 정보