RegisterDaemonTaskDefinition - Amazon Elastic Container Service

RegisterDaemonTaskDefinition

Registers a new daemon task definition from the supplied family and containerDefinitions. Optionally, you can add data volumes to your containers with the volumes parameter. For more information, see Daemon task definitions in the Amazon Elastic Container Service Developer Guide.

A daemon task definition is a template that describes the containers that form a daemon. Daemons deploy cross-cutting software agents such as security monitoring, telemetry, and logging across your Amazon ECS infrastructure.

Each time you call RegisterDaemonTaskDefinition, a new revision of the daemon task definition is created. You can't modify a revision after you register it.

Request Syntax

{ "containerDefinitions": [ { "command": [ "string" ], "cpu": number, "dependsOn": [ { "condition": "string", "containerName": "string" } ], "entryPoint": [ "string" ], "environment": [ { "name": "string", "value": "string" } ], "environmentFiles": [ { "type": "string", "value": "string" } ], "essential": boolean, "firelensConfiguration": { "options": { "string" : "string" }, "type": "string" }, "healthCheck": { "command": [ "string" ], "interval": number, "retries": number, "startPeriod": number, "timeout": number }, "image": "string", "interactive": boolean, "linuxParameters": { "capabilities": { "add": [ "string" ], "drop": [ "string" ] }, "devices": [ { "containerPath": "string", "hostPath": "string", "permissions": [ "string" ] } ], "initProcessEnabled": boolean, "tmpfs": [ { "containerPath": "string", "mountOptions": [ "string" ], "size": number } ] }, "logConfiguration": { "logDriver": "string", "options": { "string" : "string" }, "secretOptions": [ { "name": "string", "valueFrom": "string" } ] }, "memory": number, "memoryReservation": number, "mountPoints": [ { "containerPath": "string", "readOnly": boolean, "sourceVolume": "string" } ], "name": "string", "privileged": boolean, "pseudoTerminal": boolean, "readonlyRootFilesystem": boolean, "repositoryCredentials": { "credentialsParameter": "string" }, "restartPolicy": { "enabled": boolean, "ignoredExitCodes": [ number ], "restartAttemptPeriod": number }, "secrets": [ { "name": "string", "valueFrom": "string" } ], "startTimeout": number, "stopTimeout": number, "systemControls": [ { "namespace": "string", "value": "string" } ], "ulimits": [ { "hardLimit": number, "name": "string", "softLimit": number } ], "user": "string", "workingDirectory": "string" } ], "cpu": "string", "executionRoleArn": "string", "family": "string", "memory": "string", "tags": [ { "key": "string", "value": "string" } ], "taskRoleArn": "string", "volumes": [ { "host": { "sourcePath": "string" }, "name": "string" } ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

containerDefinitions

A list of container definitions in JSON format that describe the containers that make up your daemon task.

Type: Array of DaemonContainerDefinition objects

Required: Yes

cpu

The number of CPU units used by the daemon task. It can be expressed as an integer using CPU units (for example, 1024).

Type: String

Required: No

executionRoleArn

The Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make Amazon Web Services API calls on your behalf. The task execution role is required for daemon tasks that pull container images from Amazon ECR or send container logs to CloudWatch.

Type: String

Required: No

family

You must specify a family for a daemon task definition. This family is used as a name for your daemon task definition. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed.

Type: String

Required: Yes

memory

The amount of memory (in MiB) used by the daemon task. It can be expressed as an integer using MiB (for example, 1024).

Type: String

Required: No

tags

The metadata that you apply to the daemon task definition to help you categorize and organize them. Each tag consists of a key and an optional value. You define both of them.

The following basic restrictions apply to tags:

  • Maximum number of tags per resource - 50

  • For each resource, each tag key must be unique, and each tag key can have only one value.

  • Maximum key length - 128 Unicode characters in UTF-8

  • Maximum value length - 256 Unicode characters in UTF-8

  • If your tagging schema is used across multiple services and resources, remember that other services may have restrictions on allowed characters. Generally allowed characters are: letters, numbers, and spaces representable in UTF-8, and the following characters: + - = . _ : / @.

  • Tag keys and values are case-sensitive.

  • Do not use aws:, AWS:, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for AWS use. You cannot edit or delete tag keys or values with this prefix. Tags with this prefix do not count against your tags per resource limit.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

Required: No

taskRoleArn

The short name or full Amazon Resource Name (ARN) of the IAM role that containers in this daemon task can assume. All containers in this daemon task are granted the permissions that are specified in this role.

Type: String

Required: No

volumes

A list of volume definitions in JSON format that containers in your daemon task can use.

Type: Array of DaemonVolume objects

Required: No

Response Syntax

{ "daemonTaskDefinitionArn": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

daemonTaskDefinitionArn

The full Amazon Resource Name (ARN) of the registered daemon task definition.

Type: String

Errors

For information about the errors that are common to all actions, see Common Error Types.

AccessDeniedException

You don't have authorization to perform the requested action.

message

Message that describes the cause of the exception.

HTTP Status Code: 400

ClientException

These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.

message

Message that describes the cause of the exception.

HTTP Status Code: 400

InvalidParameterException

The specified parameter isn't valid. Review the available parameters for the API request.

For more information about service event errors, see Amazon ECS service event messages.

message

Message that describes the cause of the exception.

HTTP Status Code: 400

LimitExceededException

The limit for the resource was exceeded.

message

Message that describes the cause of the exception.

HTTP Status Code: 400

ServerException

These errors are usually caused by a server issue.

message

Message that describes the cause of the exception.

HTTP Status Code: 500

Examples

In the following example or examples, the Authorization header contents (AUTHPARAMS) must be replaced with an AWS Signature Version 4 signature. For more information, see Signature Version 4 Signing Process in the AWS General Reference.

You only need to learn how to sign HTTP requests if you intend to create them manually. When you use the AWS Command Line Interface or one of the AWS SDKs to make requests to AWS, these tools automatically sign the requests for you, with the access key that you specify when you configure the tools. When you use these tools, you don't have to sign requests yourself.

Example

This example registers a daemon task definition in the monitoring-agent family with a single container that runs a CloudWatch agent.

Sample Request

POST / HTTP/1.1 Host: ecs.us-east-1.amazonaws.com Accept-Encoding: identity X-Amz-Target: AmazonEC2ContainerServiceV20141113.RegisterDaemonTaskDefinition X-Amz-Date: 20250315T103000Z Content-Type: application/x-amz-json-1.1 Authorization: AUTHPARAMS { "family": "monitoring-agent", "containerDefinitions": [ { "name": "cloudwatch-agent", "image": "public.ecr.aws/cloudwatch-agent/cloudwatch-agent:latest", "memory": 256, "cpu": 128, "essential": true, "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/daemon/monitoring-agent", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "ecs" } }, "environment": [ { "name": "USE_DEFAULT_CONFIG", "value": "true" } ] } ], "cpu": "128", "memory": "256", "executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", "taskRoleArn": "arn:aws:iam::123456789012:role/ecsDaemonTaskRole" }

Sample Response

HTTP/1.1 200 OK Server: Server Date: Sat, 15 Mar 2025 10:30:00 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 97 Connection: keep-alive x-amzn-RequestId: 123a4b56-7c89-01d2-3ef4-example5678f { "daemonTaskDefinitionArn": "arn:aws:ecs:us-east-1:123456789012:daemon-task-definition/monitoring-agent:1" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: