ecs_composex.ecs_cluster package

Submodules

ecs_composex.ecs_cluster.ecs_cluster_params module

ecs_composex.ecs_cluster.ecs_family_helpers module

ecs_composex.ecs_cluster.ecs_family_helpers. set_launch_type_from_cluster_and_service ( family , cluster ) [source]

Sets the launch type based on the service and capacity providers

If all the capacity providers of the service are FARGATE, we use FARGATE_PROVIDERS which removes LaunchType from ECS Service definition Otherwise, we use the capacity providers set which use AutoScaling.

Return type :

None

ecs_composex.ecs_cluster.ecs_family_helpers. set_launch_type_from_cluster_only ( family , cluster ) [source]

When the family x-ecs has not set CapacityProviders, we rely on the ECS Cluster definition. If all the capacity providers defined on the Cluster are FARGATE related, use FARGATE_PROVIDERS Otherwise, use the ECS Cluster defined capacity providers based on the Cluster strategy.

Return type :

None

ecs_composex.ecs_cluster.ecs_family_helpers. set_service_launch_type ( family , cluster ) [source]

Sets the LaunchType value for the ECS Service If the LaunchType is EXTERNAL or EC2, we ignore Capacity Providers altogether.

Return type :

None

ecs_composex.ecs_cluster.ecs_family_helpers. validate_capacity_providers ( family , cluster ) [source]

Validates that the defined ecs_capacity_providers are all available in the ECS Cluster Providers

Raises :

ValueError if not all task family providers in the cluster providers

Raises :

TypeError if cluster_providers not a list

Return type :

bool

ecs_composex.ecs_cluster.ecs_family_helpers. validate_compute_configuration_for_task ( family , settings ) [source]

Function to perform a final validation of compute before rendering.

Return type :

None

ecs_composex.ecs_cluster.helpers module

ecs_composex.ecs_cluster.helpers. evaluate_capacity_providers ( cluster_def ) [source]

When using Looked’Up cluster, if there is no Fargate Capacity Provider, defined on cluster, rollback to EC2 mode.

Parameters :

cluster_def ( dict ) –

Returns :

List of capacity providers set on the ECS Cluster.

Return type :

list

ecs_composex.ecs_cluster.helpers. evaluate_fargate_is_set ( providers , cluster_def ) [source]

Evaluate if FARGATE or FARGATE_SPOT is defined in the cluster

Parameters :
  • providers ( list [ str ] ) –

  • cluster_def ( dict ) –

Returns :

Whether FARGATE or FARGATE_SPOT is available

Return type :

bool

ecs_composex.ecs_cluster.helpers. get_default_capacity_strategy ( cluster_def ) [source]
ecs_composex.ecs_cluster.helpers. import_from_x_aws_cluster ( compose_content ) [source]

Function to handle and override settings if x-aws-cluster is defined.

Parameters :

compose_content

Returns :

ecs_composex.ecs_cluster.helpers. set_ecs_cluster_identifier ( root_stack , settings ) [source]

Final pass at the top stacks parameters to set the ECS cluster parameter

Parameters :
Return type :

None

Module contents

class ecs_composex.ecs_cluster. EcsCluster ( root_stack , definition = None , ** kwargs ) [source]

Bases: object

Class to make it easier to manipulate the ECS Cluster to use and its various properties

define_cluster ( root_stack , settings ) [source]

Function to create the cluster from provided properties.

import_log_config ( exec_config ) [source]

Sets the properties for bucket and cw log group to use for ECS Execute

Parameters :

exec_config ( dict ) –

Returns :

lookup_cluster ( session ) [source]

Define the ECS Cluster properties and definitions from ECS API.

Parameters :

session ( boto3.session.Session ) – Boto3 session to make API calls.

Returns :

The cluster details

Return type :

dict

mappings_key = 'ecs'
res_key = 'x-cluster'
set_cluster_mappings ( cluster_api_def ) [source]

From the API info on the cluster, evaluate whether config is needed to enable ECS Execution

Parameters :

cluster_api_def ( dict ) –

set_default_cluster_config ( root_stack ) [source]

Function to get the default defined ECS Cluster configuration

Returns :

cluster

Return type :

troposphere.ecs.Cluster

set_from_definition ( root_stack , session , settings ) [source]
set_kms_key ( cluster_name , settings , log_settings , log_configuration ) [source]

Defines the KMS Key created to encrypt ECS Execute commands

Parameters :
set_log_bucket ( cluster_name , settings , log_configuration ) [source]

Defines the S3 bucket and settings to log ECS Execution commands

Parameters :
Returns :

set_log_group ( cluster_name , root_stack , log_configuration ) [source]
update_props_from_parameters ( cluster_name , root_stack , settings ) [source]

Adapt cluster config to settings

ecs_composex.ecs_cluster. add_ecs_cluster ( settings ) [source]

Function to create the ECS Cluster.

Parameters :

settings ( ecs_composex.common.settings.ComposeXSettings ) –

ecs_composex.ecs_cluster. get_kms_key_config ( cluster_name , allow_kms_reuse = False ) [source]