Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws ecs execute-command failed because was not enabled

I am running aws ecs execute-command --cluster UltimaF --task 838d773b17954bcfbbacf343fb4fea70 --container ultima --interactive --command "/bin/sh"

Getting back: 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.

I have ensured that:

  1. The task is running.
  2. aws ecs describe-tasks --cluster UltimaF --tasks 838d773b17954bcfbbacf343fb4fea70 returns "enableExecuteCommand": true
  3. Task role has the following permissions attached:
    • ssmmessages:CreateControlChannel
    • ssmmessages:CreateDataChannel
    • ssmmessages:OpenControlChannel
    • ssmmessages:OpenDataChannel

I am running on Windows, aws-cli/2.8.2

UPDATE: after running ecs exec checker I have two yellow items and one red:

    ----------
      Managed Agent Status
    ----------
         1. STOPPED (Reason: null) for "ultima" - LastStartedAt: null
    ----------
      Init Process Enabled (first-run-task-definition:12)
    ----------
         1. Disabled - "ultima" 

UPDATE two:

This issue suggests ecs:clustername_taskid_containerruntimeid but for me it returns an error: An error occurred (TargetNotConnected) when calling the StartSession operation: ecs:UltimaF_838d773b17954bcfbbacf343fb4fea70_838d773b17954bcfbbacf343fb4fea70-2587323273 is not connected.

Question: How do I connect?

like image 252
Anatoly Bugakov Avatar asked Dec 18 '25 08:12

Anatoly Bugakov


2 Answers

Try this

  1. https://dev.to/aws-builders/how-to-run-a-shell-on-ecs-fargate-containers-eo1
  2. aws ecs update-service --cluster <cluster-name> --service <service-name> --force-new-deployment --enable-execute-command.

This will enable it

like image 199
JTX Avatar answered Dec 20 '25 04:12

JTX


Make sure that in your task definition's structure/JSON "enableExecuteCommand" is set to true.

aws ecs describe-tasks --cluster <CLUSTER> --tasks <TASK_ARN>

like image 38
Mohamad El Bohsaly Avatar answered Dec 20 '25 04:12

Mohamad El Bohsaly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!