1

I've got a Task Definition with parameters which executes a script using a regular user.

I'd like to test the script without changing the Task Definition by overriding the default user which script is running by using --overrides parameter of aws run-task command. For example:

$ aws ecs run-task \
    --profile myprofile \
    --cluster foo \
    --task-definition mytask \
    --overrides '{"containerOverrides":[{"user": "root"}]}'

It returns:

Parameter validation failed: Unknown parameter in overrides.containerOverrides[0]: "user", must be one of: name, command, environment, cpu, memory, memoryReservation.

And when running with containerDefinitions key:

$ aws ecs run-task \
    --profile myprofile \
    --cluster foo \
    --task-definition mytask \
    --overrides '{"containerDefinitions":[{"user": "root"}]}'

I've got this error:

Parameter validation failed: Unknown parameter in overrides: "containerDefinitions", must be one of: containerOverrides, taskRoleArn, executionRoleArn


I've found the post how to change the environment variables using aws ecs run-task, but it's not clear how to change the user. Help page isn't clear as well (aws ecs run-task help).


Here is my task definition:

$ aws ecs describe-task-definition --profile myprofile --task-definition mytask
{
    "taskDefinition": {
        "taskDefinitionArn": "...",
        "containerDefinitions": [
            {
                "name": "post_deploy",
                "image": "...dkr.ecr.eu-west-1.amazonaws.com/..",
                "command": [
                    "bash",
                    "post_deploy.sh"
                ],
                "user": "ubuntu", <!--- I'd like to override this!
            }
        ],
        "status": "ACTIVE",
        ...
    }
}

How this can be achieved?

| improve this question | | | | |
  • Please describe what you are trying to achieve. Could you explain what issue you are trying to solve? I'd like to test the script without changing the Task Definition – 030 Dec 24 '19 at 18:55