오류 해결/AWS 오류 해결

[오류 해결] TargetNotConnectedException - ECS

dalgong 2025. 1. 13. 13:34
반응형

1. Error

[root@ip-172-20-0-181 ~]# aws ecs execute-command --profile hlpark-ecr-user --cluster hlpark-ecs-test --task arn:aws:ecs:ap-northeast-2:859234351948:task/hlpark-ecs-test/70948fbf3e244606b46819138172189e --container hlpark-ecs-test --command "/bin/sh" --interactive

The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.


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

2. 해결 방법

  • IAM - 정책 - 정책 생성 - JSON - 아래 정책 복사하여 생성
{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Effect": "Allow",
			"Action": [
				"ssmmessages:CreateControlChannel",
				"ssmmessages:CreateDataChannel",
				"ssmmessages:OpenControlChannel",
				"ssmmessages:OpenDataChannel"
			],
			"Resource": "*"
		}
	]
}
  • IAM -> 역할 -> 원하는 태스크 정의에 들어가 있는 태스크 실행 역할 클릭 -> 방금 생성한 정책 추가 -> 태스크 삭제 후 재배포 -> 다시 접속 태스크
  • 태스크 실행 역할 확인 방법 : ECS -> 태스크 정의 -> 원하는 태스크 정의 선택 -> 원하는 태스크 정의: 개정 선택 -> 태스크 실행 역할 확인

반응형