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
storm
已提問 4 個月前檢視次數 388 次
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)

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南