bot3 ecs.execute_command: Task Identifier is invalid

27 Views Asked by At

I have defined a task in AWS ECS. I have copied the task ARN into the API call:

rsp = ecs.execute_command(
        container='test',
        command=json.dumps(event),
        task='arn:aws:ecs:##-####-#:############:task-definition/test:1',
        interactive=True
    )

I receive the following error complaining about the task identifier:

botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the ExecuteCommand operation: Task Identifier is invalid

I am not sure what is wrong as the task identifier has been copied from the AWS web interface where the task was created. Am I just missing something extremely obvious?

1

There are 1 best solutions below

1
Felpower On BEST ANSWER

Double Check the Components: A valid ECS task ARN looks something like this:

arn:aws:ecs:[region]:[account-id]:task/[cluster-name]/[task-id]

Distinguish between Task Definition ARN and Task ARN, they are different.

Check if the Task is in the "RUNNING" State

Check your Permission, do you have the correct IAM role?