How to enable my Task scale-in protection endpoint

0

When I try to start a task running on EC2, I use SSH to log into the container and use

curl --request PUT --header 'Content-Type: application/json' ${ECS_AGENT_URI}/task-protection/v1/state --data '{"ProtectionEnabled":true}'

to enable the Task scale-in protection endpoint. However, I found that the ECS_AGENT_URI is not in my environment variables. result is

curl: (3) URL rejected: No host part in the URL
1개 답변
1

Does the ECS task role have a policy which allows the 2 following IAM Permissions?

  • ecs:GetTaskProtection:
  • ecs:UpdateTaskProtection

What version of the ECS Container agent are you running? It needs to be 1.65.0 or later

How To:- https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/aws/ECS/latest-agent-version.html

profile picture
전문가
답변함 4달 전
  • thanks. I have try to add the policy:

    {
    	"Version": "2012-10-17",
    	"Statement": [
    		{
    			"Effect": "Allow",
    			"Action": [
    				"ecs:GetTaskProtection",
    				"ecs:UpdateTaskProtection"
    			],
    			"Resource": "*"
    		}
    	]
    }
    

    into my ec2 ECS task role and definition task role , but still

    [root@47a50edab60a ~]# curl --request PUT --header 'Content-Type: application/json' ${ECS_AGENT_URI}/task-protection/v1/state --data '{"ProtectionEnabled":true}'
    curl: (3) URL rejected: No host part in the URL
    

    my ecs-agent version is 1.79.2 and the doc mentioned with the "This operation is only supported for tasks belonging to an Amazon ECS service. Invoking this operation for a standalone task will result in an TASK_NOT_VALID failure." https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateTaskProtection.html maybe my task is standalone task? But my task is running as ecs task in ec2 auto scaling.

  • EC2 AutoScaling is for launching instances into your cluster. You can then either launch standalone tasks onto those cluster instances, or create an ECS Service to manage multiple tasks for the same Task Definition. If you went through the workflow of launching a single task, its a standalone task.

    However, I don't think shouldn't be causing the error you see now (it might cause an error after this first one is fixed, but your failure is earlier in the process)

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠