Skip to content

create_daemon

create_daemon(
    daemon_name: String,
    daemon_task_definition_arn: String,
    capacity_provider_arns: StringList,
    *,
    config_overrides: Optional[ECSClientConfig] = None,
    cluster_arn: Optional[String] = None,
    deployment_configuration: Optional[DaemonDeploymentConfiguration] = None,
    tags: Optional[Tags] = None,
    propagate_tags: Optional[DaemonPropagateTags] = None,
    enable_ecs_managed_tags: Optional[Boolean] = None,
    enable_execute_command: Optional[Boolean] = None,
    client_token: Optional[String] = None,
    critical: Optional[BoxedBoolean] = None,
) -> CreateDaemonResponse

Creates a new daemon in the specified cluster and capacity providers. A daemon deploys cross-cutting software agents such as security monitoring, telemetry, and logging independently across your Amazon ECS infrastructure.

Amazon ECS deploys exactly one daemon task on each container instance of the specified capacity providers. When a container instance registers with the cluster, Amazon ECS automatically starts daemon tasks. Amazon ECS starts a daemon task before scheduling other tasks.

Daemons are essential for instance health - if a daemon task stops, Amazon ECS automatically drains and replaces that container instance.

ECS Managed Daemons is only supported for Amazon ECS Managed Instances Capacity Providers.

Parameters:

  • daemon_name (String) –

    The name of the daemon. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed.

  • cluster_arn (Optional[String], default: None ) –

    The Amazon Resource Name (ARN) of the cluster to create the daemon in.

  • daemon_task_definition_arn (String) –

    The Amazon Resource Name (ARN) of the daemon task definition to use for the daemon.

  • capacity_provider_arns (StringList) –

    The Amazon Resource Names (ARNs) of the capacity providers to associate with the daemon. The daemon deploys tasks on container instances managed by these capacity providers.

  • deployment_configuration (Optional[DaemonDeploymentConfiguration], default: None ) –

    Optional deployment parameters that control how the daemon rolls out updates, including the drain percentage, alarm-based rollback, and bake time.

  • tags (Optional[Tags], default: None ) –

    The metadata that you apply to the daemon 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 Amazon Web Services 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.

  • propagate_tags (Optional[DaemonPropagateTags], default: None ) –

    Specifies whether to propagate the tags from the daemon to the daemon tasks. If you don't specify a value, the tags aren't propagated. You can only propagate tags to daemon tasks during task creation. To add tags to a task after task creation, use the TagResource API action.

  • enable_ecs_managed_tags (Optional[Boolean], default: None ) –

    Specifies whether to turn on Amazon ECS managed tags for the tasks in the daemon. For more information, see Tagging your Amazon ECS resources in the Amazon Elastic Container Service Developer Guide.

  • enable_execute_command (Optional[Boolean], default: None ) –

    Determines whether the execute command functionality is turned on for the daemon. If true, the execute command functionality is turned on for all tasks in the daemon.

  • client_token (Optional[String], default: None ) –

    An identifier that you provide to ensure the idempotency of the request. It must be unique and is case sensitive. Up to 36 ASCII characters in the range of 33-126 (inclusive) are allowed.

  • critical (Optional[BoxedBoolean], default: None ) –

    If the critical parameter of a daemon is true, and the daemon task fails, stops, or becomes unhealthy, Amazon ECS drains the container instance and stops the other tasks running on it. If the critical parameter is false, the daemon task failure doesn't affect the other tasks on the instance. The default value is true.

    A non-critical daemon doesn't block instance registration. The container instance becomes active and continues to run your other tasks, whether the daemon task fails during scale-out or during a deployment.

    Amazon ECS emits an EventBridge event when a daemon task fails to start, for both critical and non-critical daemons.

    Daemon task launch failures during a deployment are still counted by the deployment circuit breaker. The circuit breaker can roll back an unstable target revision.

Raises:

Examples:

To create a daemon This example creates a daemon named my-monitoring-daemon in the specified cluster that uses the monitoring-agent daemon task definition and deploys to the specified capacity provider.

>>> client.create_daemon(daemon_name='my-monitoring-daemon', cluster_arn='arn:aws:ecs:us-east-1:123456789012:cluster/my-cluster', daemon_task_definition_arn='arn:aws:ecs:us-east-1:123456789012:daemon-task-definition/monitoring-agent:1', capacity_provider_arns=['arn:aws:ecs:us-east-1:123456789012:capacity-provider/my-capacity-provider'], deployment_configuration={'drainPercent': 10.0, 'bakeTimeInMinutes': 5})
Source code in docs_src/capo_ecs/_services/ecs.py
def create_daemon(
    self,
    daemon_name: "capo_ecs.types.string.String",
    daemon_task_definition_arn: "capo_ecs.types.string.String",
    capacity_provider_arns: "capo_ecs.types.string_list.StringList",
    *,
    config_overrides: Optional[ECSClientConfig] = None,
    cluster_arn: Optional["capo_ecs.types.string.String"] = None,
    deployment_configuration: Optional[
        "capo_ecs.types.daemon_deployment_configuration.DaemonDeploymentConfiguration"
    ] = None,
    tags: Optional["capo_ecs.types.tags.Tags"] = None,
    propagate_tags: Optional[
        "capo_ecs.types.daemon_propagate_tags.DaemonPropagateTags"
    ] = None,
    enable_ecs_managed_tags: Optional["capo_ecs.types.boolean.Boolean"] = None,
    enable_execute_command: Optional["capo_ecs.types.boolean.Boolean"] = None,
    client_token: Optional["capo_ecs.types.string.String"] = None,
    critical: Optional["capo_ecs.types.boxed_boolean.BoxedBoolean"] = None,
) -> "capo_ecs.types.create_daemon_response.CreateDaemonResponse":
    """<p>Creates a new daemon in the specified cluster and capacity providers. A daemon deploys cross-cutting software agents such as security monitoring, telemetry, and logging independently across your Amazon ECS infrastructure.</p> <p>Amazon ECS deploys exactly one daemon task on each container instance of the specified capacity providers. When a container instance registers with the cluster, Amazon ECS automatically starts daemon tasks. Amazon ECS starts a daemon task before scheduling other tasks.</p> <p>Daemons are essential for instance health - if a daemon task stops, Amazon ECS automatically drains and replaces that container instance.</p> <note> <p>ECS Managed Daemons is only supported for Amazon ECS Managed Instances Capacity Providers.</p> </note>

    Args:
        daemon_name: <p>The name of the daemon. Up to 255 letters (uppercase and lowercase), numbers, underscores, and hyphens are allowed.</p>
        cluster_arn: <p>The Amazon Resource Name (ARN) of the cluster to create the daemon in.</p>
        daemon_task_definition_arn: <p>The Amazon Resource Name (ARN) of the daemon task definition to use for the daemon.</p>
        capacity_provider_arns: <p>The Amazon Resource Names (ARNs) of the capacity providers to associate with the daemon. The daemon deploys tasks on container instances managed by these capacity providers.</p>
        deployment_configuration: <p>Optional deployment parameters that control how the daemon rolls out updates, including the drain percentage, alarm-based rollback, and bake time.</p>
        tags: <p>The metadata that you apply to the daemon to help you categorize and organize them. Each tag consists of a key and an optional value. You define both of them.</p> <p>The following basic restrictions apply to tags:</p> <ul> <li> <p>Maximum number of tags per resource - 50</p> </li> <li> <p>For each resource, each tag key must be unique, and each tag key can have only one value.</p> </li> <li> <p>Maximum key length - 128 Unicode characters in UTF-8</p> </li> <li> <p>Maximum value length - 256 Unicode characters in UTF-8</p> </li> <li> <p>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: + - = . _ : / @.</p> </li> <li> <p>Tag keys and values are case-sensitive.</p> </li> <li> <p>Do not use <code>aws:</code>, <code>AWS:</code>, or any upper or lowercase combination of such as a prefix for either keys or values as it is reserved for Amazon Web Services 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.</p> </li> </ul>
        propagate_tags: <p>Specifies whether to propagate the tags from the daemon to the daemon tasks. If you don't specify a value, the tags aren't propagated. You can only propagate tags to daemon tasks during task creation. To add tags to a task after task creation, use the <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TagResource.html">TagResource</a> API action.</p>
        enable_ecs_managed_tags: <p>Specifies whether to turn on Amazon ECS managed tags for the tasks in the daemon. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html">Tagging your Amazon ECS resources</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</p>
        enable_execute_command: <p>Determines whether the execute command functionality is turned on for the daemon. If <code>true</code>, the execute command functionality is turned on for all tasks in the daemon.</p>
        client_token: <p>An identifier that you provide to ensure the idempotency of the request. It must be unique and is case sensitive. Up to 36 ASCII characters in the range of 33-126 (inclusive) are allowed.</p>
        critical: <p>If the <code>critical</code> parameter of a daemon is <code>true</code>, and the daemon task fails, stops, or becomes unhealthy, Amazon ECS drains the container instance and stops the other tasks running on it. If the <code>critical</code> parameter is <code>false</code>, the daemon task failure doesn't affect the other tasks on the instance. The default value is <code>true</code>.</p> <p>A non-critical daemon doesn't block instance registration. The container instance becomes active and continues to run your other tasks, whether the daemon task fails during scale-out or during a deployment.</p> <p>Amazon ECS emits an EventBridge event when a daemon task fails to start, for both critical and non-critical daemons.</p> <p>Daemon task launch failures during a deployment are still counted by the deployment circuit breaker. The circuit breaker can roll back an unstable target revision.</p>

    Raises:
        capo_ecs.errors.access_denied_exception.AccessDeniedException: <p>You don't have authorization to perform the requested action.</p>
        capo_ecs.errors.client_exception.ClientException: <p>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.</p>
        capo_ecs.errors.cluster_not_found_exception.ClusterNotFoundException: <p>The specified cluster wasn't found. You can view your available clusters with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html">ListClusters</a>. Amazon ECS clusters are Region specific.</p>
        capo_ecs.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter isn't valid. Review the available parameters for the API request.</p> <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
        capo_ecs.errors.platform_unknown_exception.PlatformUnknownException: <p>The specified platform version doesn't exist.</p>
        capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_ecs.errors.unsupported_feature_exception.UnsupportedFeatureException: <p>The specified task isn't supported in this Region.</p>
        capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a daemon
        This example creates a daemon named my-monitoring-daemon in the specified cluster that uses the monitoring-agent daemon task definition and deploys to the specified capacity provider.

        >>> client.create_daemon(daemon_name='my-monitoring-daemon', cluster_arn='arn:aws:ecs:us-east-1:123456789012:cluster/my-cluster', daemon_task_definition_arn='arn:aws:ecs:us-east-1:123456789012:daemon-task-definition/monitoring-agent:1', capacity_provider_arns=['arn:aws:ecs:us-east-1:123456789012:capacity-provider/my-capacity-provider'], deployment_configuration={'drainPercent': 10.0, 'bakeTimeInMinutes': 5})
    """

    def _handler(
        req: "OperationRequest[capo_ecs.types.create_daemon_request.CreateDaemonRequest]",
    ) -> OperationResponse[
        "capo_ecs.types.create_daemon_response.CreateDaemonResponse"
    ]:
        import capo_ecs._operations.amazon_ec2_container_service_v20141113.create_daemon

        output, http_response = (
            capo_ecs._operations.amazon_ec2_container_service_v20141113.create_daemon.create_daemon(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDaemon")
    )
    input_: capo_ecs.types.create_daemon_request.CreateDaemonRequest = {
        "daemon_name": daemon_name,
        "daemon_task_definition_arn": daemon_task_definition_arn,
        "capacity_provider_arns": capacity_provider_arns,
    }
    if cluster_arn is not None:
        input_["cluster_arn"] = cluster_arn
    if deployment_configuration is not None:
        input_["deployment_configuration"] = deployment_configuration
    if tags is not None:
        input_["tags"] = tags
    if propagate_tags is not None:
        input_["propagate_tags"] = propagate_tags
    if enable_ecs_managed_tags is not None:
        input_["enable_ecs_managed_tags"] = enable_ecs_managed_tags
    if enable_execute_command is not None:
        input_["enable_execute_command"] = enable_execute_command
    if client_token is not None:
        input_["client_token"] = client_token
    if critical is not None:
        input_["critical"] = critical

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output