aws ecs update-service \
--cluster 클러스터명 \
--service 서비스명 \
--enable-execute-command
aws ecs describe-tasks \
--cluster cluster-name \
--tasks task-id
aws ecs execute-command --cluster 클러스터명 \
--task 태스크명 \
--container 컨테이너명 \
--interactive \
--command "/bin/sh"
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 내용 추가
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": "*"
}
]
}
https://docs.aws.amazon.com/ko_kr/AmazonECS/latest/developerguide/ecs-exec.html