Skip to content

EcsService

Bases: DuploResourceV2

Manage Duplo ECS Resources

A collection of commands to manage ECS services and task definitions.

Commands

apply

Apply an ECS Service.

Create or update an ECS service.

CLI Usage
duploctl ecs apply -f 'ecs_service.yaml'

Returns:

Name Type Description
message dict

A success message.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction
--wait, -w
Wait for the operation to complete

create_service

Create an ECS service.

Returns:

Name Type Description
message dict

A success message.

Raises:

Type Description
DuploError

If the ECS service could not be created.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction

delete_service

Delete an ECS service.

Returns:

Name Type Description
message dict

A message indicating the service has been deleted.

Parameters:

name positional
The resource name
str

find

Find a EcsService by name.

cli usage
duploctl ecsservice find <name>

Returns:

Name Type Description
resource dict

The EcsService object.

Raises:

Type Description
DuploError

If the {{kind}} could not be found.

Parameters:

name positional
The resource name
str

find_def

Find the latest version of an ECS task definition by family name.

Returns:

Name Type Description
task_definition

The latest version of that ECS task definition in the family.

Raises:

Type Description
DuploError

If the ECS task definition could not be found.

Parameters:

name positional
The resource name
str

find_def_by_arn

Find a ECS task definition by ARN.

Find a task definition by its AWS ARN.

Returns:

Name Type Description
task_definition dict

The ECS task definition object.

Raises:

Type Description
DuploError

If the ECS task definition could not be found.

Parameters:

--aws-arn, --arn
The aws arn
str

find_service_family

Find Service Family by Name

Find an ECS Services task definition family by name.

Returns:

Name Type Description
task_definition_family

The ECS task definition object.

Raises:

Type Description
DuploError

If the ECS task definition could not be found.

Parameters:

name positional
The resource name
str

find_task_def_family

Find a ECS task definition family by name.

Returns:

Type Description

The ECS task definition object.

Raises:

Type Description
DuploError

If the ECS task definition could not be found.

Parameters:

name positional
The resource name
str

list

Retrieve a List of EcsService

cli usage
duploctl ecsservice list

Returns:

Name Type Description
list list

A list of EcsService.

list_services

List ECS Services

Retrieve a list of all ECS services in a tenant.

CLI Usage
duploctl ecs list_services

Returns:

Name Type Description
list list

A list of ECS services in the tenant.

list_task_def_family

List ECS Task Definitions

Retrieve a list of all ECS task definitions in a tenant.

Example

CLI usage

duploctl ecs list_definitions

Returns:

Name Type Description
task_def_family dict

The historical list of ECS task definitions within a family.

list_tasks

List Tasks

List ECS tasks given a name.

Basic CLI Use
duploctl ecs list_tasks <service-name>

Returns:

Name Type Description
list list

A list of ECS tasks associated with the service.

Parameters:

name positional
The resource name
str

run_task

Run a task from an ECS task definition family's latest definition version."

Execute a task based on some definition.

Basic CLI Use
duploctl ecs run_task <task-definition-family-name> <replicas>
Wait for task to complete

This supports the global --wait flag to hold the terminal until the task is complete. Waits for the status of the task to be the desired complete status.

duploctl ecs run_task myapp 3 --wait

Returns:

Name Type Description
message dict

A message indicating the task has been run.

Parameters:

name positional
The resource name
str
--replicas, -r
Number of replicas for service
int

update_image

Update Image

Creates a new task definition version cloning the latest existing version in the family except for image arguments

If task family is used by an ECS service, method also updates the service to use that newly created definition version

Basic CLI Use

  duploctl ecs update_image <task-definition-family-name> <new-image>
  duploctl ecs update_image <task-definition-family-name> --container-image <container-name> <new-container-image>

Update image and wait

This supports the global --wait flag to hold the terminal until the service update is complete. Waits for the status of the service to be the desired running status.

  duploctl ecs update_image myapp myimage:latest --wait

Returns:

Name Type Description
dict dict

A dictionary containing a message about the update status.

Raises:

Type Description
DuploError

If the ECS task definition family could not be updated.

Parameters:

name positional
The resource name
str
image positional
The image to use
str
--container-image, --container-image <key> <value> repeatable
a key and value to set as a side-car container name and image
str nargs: 2

update_service

Update an ECS service.

Returns:

Name Type Description
message dict

A success message.

Raises:

Type Description
DuploError

If the ECS service could not be updated.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction

update_taskdef

Update an ECS task definition.

Updates a task definition. This creates a new revision of the task definition and returns the new ARN. Note each definition is immutable so this is effectively a create operation for one item in a set and the latest one is the active one.

Returns:

Name Type Description
task_definition dict

The updated ECS task definition object.

Raises:

Type Description
DuploError

If the ECS task definition could not be updated.

Parameters:

--file, -f, --cli-input
A file to read the input from
FileType('r') action: YamlAction

Methods

list_detailed_services

List detailed ECS Services

Retrieve a list of all detailed ECS services in a tenant.

Returns:

Name Type Description
list list

A list of detailed ECS services in the tenant.