libcloud.container.drivers.ecs module

class libcloud.container.drivers.ecs.ElasticContainerDriver(access_id, secret, region)[source]

Bases: ContainerDriver

Parameters:
  • key (str) – API key or username to used (required)

  • secret (str) – Secret password to be used (required)

  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.

  • host (str) – Override hostname used for connections.

  • port (int) – Override port used for connections.

Returns:

None

connectionCls

alias of ECSJsonConnection

create_cluster(name, location=None)[source]

Create a container cluster

Parameters:
Return type:

libcloud.container.base.ContainerCluster

deploy_container(name, image, cluster=None, parameters=None, start=True, ex_cpu=10, ex_memory=500, ex_container_port=None, ex_host_port=None)[source]

Creates a task definition from a container image that can be run in a cluster.

Parameters:
Return type:

libcloud.container.base.Container

destroy_cluster(cluster)[source]

Delete a cluster

Returns:

True if the destroy was successful, otherwise False.

Return type:

bool

destroy_container(container)[source]

Destroy a deployed container

Parameters:

container (libcloud.container.base.Container) – The container to destroy

Return type:

libcloud.container.base.Container

ecrConnectionClass

alias of ECRJsonConnection

ecr_repository_host = '%s.dkr.ecr.%s.amazonaws.com'
ex_create_service(name, cluster, task_definition, desired_count=1)[source]

Runs and maintains a desired number of tasks from a specified task definition. If the number of tasks running in a service drops below desired_count, Amazon ECS spawns another instantiation of the task in the specified cluster.

Parameters:
  • name (str) – the name of the service

  • cluster (libcloud.container.base.ContainerCluster) – The cluster to run the service on

  • task_definition (str) – The task definition name or ARN for the service

  • desired_count (int) – The desired number of tasks to be running at any one time

Return type:

object The service object

ex_describe_service(service_arn)[source]

Get the details of a service

Parameters:
Returns:

The service object

Return type:

object

ex_destroy_service(service_arn)[source]

Deletes a service

Parameters:
ex_get_registry_client(repository_name)[source]

Get a client for an ECR repository

Parameters:

repository_name (str) – The unique name of the repository

Returns:

a docker registry API client

Return type:

libcloud.container.utils.docker.RegistryClient

ex_get_repository_id(repository_name)[source]

Get the ID of a repository

Parameters:

repository_name (str) – The unique name of the repository

Returns:

The repository ID

Return type:

str

ex_get_repository_token(repository_id)[source]

Get the authorization token (12 hour expiry) for a repository

Parameters:

repository_id (str) – The ID of the repository

Returns:

A token for login

Return type:

str

ex_list_containers_for_task(task_arns)[source]

Get a list of containers by ID collection (ARN)

Parameters:

task_arns (list of str) – The list of ARNs

Return type:

list of libcloud.container.base.Container

ex_list_service_arns(cluster=None)[source]

List the services

Parameters:

cluster (libcloud.container.base.ContainerCluster) – The cluster hosting the services

Return type:

list of str

ex_start_task(task_arn, count=1)[source]

Run a task definition and get the containers

Parameters:
  • task_arn (str) – The task ARN to Run

  • count (int) – The number of containers to start

Return type:

list of libcloud.container.base.Container

get_container(id)[source]

Get a container by ID

Parameters:

id (str) – The ID of the container to get

Return type:

libcloud.container.base.Container

list_clusters()[source]

Get a list of potential locations to deploy clusters into

Parameters:

location (libcloud.container.base.ClusterLocation) – The location to search in

Return type:

list of libcloud.container.base.ContainerCluster

list_containers(image=None, cluster=None)[source]

List the deployed container images

Parameters:
Return type:

list of libcloud.container.base.Container

list_images(ex_repository_name)[source]

List the images in an ECR repository

Parameters:

ex_repository_name (str) – The name of the repository to check defaults to the default repository.

Returns:

a list of images

Return type:

list of libcloud.container.base.ContainerImage

name = 'Amazon Elastic Container Service'
restart_container(container)[source]

Restart a deployed container

Parameters:

container (libcloud.container.base.Container) – The container to restart

Return type:

libcloud.container.base.Container

start_container(container, count=1)[source]

Start a deployed task

Parameters:
Return type:

libcloud.container.base.Container

status_map = {'RUNNING': 'running'}
stop_container(container)[source]

Stop a deployed container

Parameters:

container (libcloud.container.base.Container) – The container to stop

Return type:

libcloud.container.base.Container

supports_clusters = False

Whether the driver supports containers being deployed into clusters

website = 'https://aws.amazon.com/ecs/details/'