createDaemon method

Future<CreateDaemonResponse> createDaemon({
  1. required List<String> capacityProviderArns,
  2. required String daemonName,
  3. required String daemonTaskDefinitionArn,
  4. String? clientToken,
  5. String? clusterArn,
  6. DaemonDeploymentConfiguration? deploymentConfiguration,
  7. bool? enableECSManagedTags,
  8. bool? enableExecuteCommand,
  9. DaemonPropagateTags? propagateTags,
  10. List<Tag>? tags,
})

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.

May throw AccessDeniedException. May throw ClientException. May throw ClusterNotFoundException. May throw InvalidParameterException. May throw PlatformUnknownException. May throw ServerException. May throw UnsupportedFeatureException.

Parameter capacityProviderArns : 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.

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

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

Parameter clientToken : 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.

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

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

Parameter enableECSManagedTags : 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.

Parameter enableExecuteCommand : 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.

Parameter propagateTags : 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.

Parameter tags : 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.

Implementation

Future<CreateDaemonResponse> createDaemon({
  required List<String> capacityProviderArns,
  required String daemonName,
  required String daemonTaskDefinitionArn,
  String? clientToken,
  String? clusterArn,
  DaemonDeploymentConfiguration? deploymentConfiguration,
  bool? enableECSManagedTags,
  bool? enableExecuteCommand,
  DaemonPropagateTags? propagateTags,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonEC2ContainerServiceV20141113.CreateDaemon'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'capacityProviderArns': capacityProviderArns,
      'daemonName': daemonName,
      'daemonTaskDefinitionArn': daemonTaskDefinitionArn,
      if (clientToken != null) 'clientToken': clientToken,
      if (clusterArn != null) 'clusterArn': clusterArn,
      if (deploymentConfiguration != null)
        'deploymentConfiguration': deploymentConfiguration,
      if (enableECSManagedTags != null)
        'enableECSManagedTags': enableECSManagedTags,
      if (enableExecuteCommand != null)
        'enableExecuteCommand': enableExecuteCommand,
      if (propagateTags != null) 'propagateTags': propagateTags.value,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateDaemonResponse.fromJson(jsonResponse.body);
}