ecs_composex.ecs.ecs_family package

Subpackages

Submodules

ecs_composex.ecs.ecs_family.family_template module

ecs_composex.ecs.ecs_family.family_template. set_template ( family ) [source]

Function to set the troposphere.Template associated with the ECS Service Family

Return type :

troposphere.Template

ecs_composex.ecs.ecs_family.task_execute_command module

Module to enable ECS Anywhere feature for a given ECS Family.

ecs_composex.ecs.ecs_family.task_execute_command. apply_ecs_execute_command_permissions ( family , settings ) [source]

Set the IAM Policies in place to allow ECS Execute SSM and Logging

Parameters :

settings

Returns :

ecs_composex.ecs.ecs_family.task_execute_command. expand_policy_roles ( role_stack , policy_title , task_role ) [source]

Adds the task role to the policy when the policy already exists

Parameters :
  • role_stack

  • policy_title ( str ) –

  • task_role

Return type :

None

ecs_composex.ecs.ecs_family.task_execute_command. set_enable_execute_command ( family ) [source]

Sets necessary settings to enable ECS Execute Command ECS Anywhere support since 2022-01-24

ecs_composex.ecs.ecs_family.task_runtime module

ecs_composex.ecs.ecs_family.task_runtime. define_family_runtime_cpu_arch ( family , svc ) [source]

Sets the CPU Runtime architecture set from services, if set. Validates that if set, it is the same for all

Raises :

ValueError

Return type :

None

ecs_composex.ecs.ecs_family.task_runtime. define_family_runtime_os_family ( family , svc ) [source]

Sets the Runtime Host OS Family set from services, if set. Validates that if set, it is the same for all

Raises :

ValueError

Return type :

None

ecs_composex.ecs.ecs_family.task_runtime. define_family_runtime_parameters ( family ) [source]

Based on the services x-ecs. Configuration, allows to change the TaskDefinition Runtime configuration

Return type :

None

Module contents

Package to manage an ECS “Family” Task and Service definition

class ecs_composex.ecs.ecs_family. ComposeFamily ( services , family_name ) [source]

Bases: object

Class to group services logically to create the final ECS Task and Service definitions

Processing order

  • Import first service

  • Define LaunchType

  • Define CapacityProviders if set

    This helps determine if we run in EXTERNAL mode early, as a lot of networking settings won’t apply.

Variables :
add_containers_images_cfn_parameters ( ) [source]

Adds parameters to the stack and set values for each service/container in the family definition

add_managed_sidecar ( service ) [source]

Adds a new container/service to the Task Family and validates all settings that go along with the change. :type service: ecs_composex.compose.compose_services.ComposeService :param service:

add_service ( service ) [source]

Function to add new services (defined in the compose files). Not to use for managed sidecars :param ComposeService service:

apply_ecs_execute_command_permissions ( settings ) [source]

Method to set the IAM Policies in place to allow ECS Execute SSM and Logging

Parameters :

settings ( ecs_composex.common.settings.ComposeXSettings ) –

Return type :

None

Returns :

composed_env_processing ( settings ) [source]
Return type :

None

finalize_family_settings ( settings ) [source]

Once all services have been added, we add the sidecars and deal with appropriate permissions and settings Will add xray / prometheus sidecars

finalize_services_networking_settings ( settings ) [source]

Final pass on the service network settings

Return type :

None

generate_outputs ( ) [source]

Generates a list of CFN outputs for the ECS Service and Task Definition

handle_alarms ( ) [source]
Return type :

None

handle_logging ( settings ) [source]

Method to go over each service logging configuration and accordingly define the IAM permissions needed for the exec/task role

import_all_sidecars ( ) [source]

Once all services have been added from the ComposeXSettings looping over services, we import all sidecars Should be invoked only once.

Return type :

None

init_family ( ) [source]

Initializes the family after all services in the docker-compose definition have been assigned.

The only containers that might then be added will be sidecars which won’t influence launch type, capacity providers or anything else than the ECS Task Definition (CPU/RAM | ProxySettings)

Return type :

None

init_network_settings ( settings , vpc_stack , families_sg_stack ) [source]

Once we have figured out the compute settings (EXTERNAL vs other)

Return type :

None

init_task_definition ( ) [source]

Initialize the ECS TaskDefinition

  • Sets Compute settings

  • Sets the TaskDefinition using current services/ContainerDefinitions

  • Update the logging configuration for the containers.

property logical_name : str
property service_arn_param : Parameter
property service_definition : Union [ None , Service ]
property service_name_param : Parameter
property services : list [ ecs_composex.compose.compose_services.ComposeService ]
property services_names : list [ str ]
set_add_region_when_external ( ) [source]
set_enable_execute_command ( ) [source]

Sets necessary settings to enable ECS Execute Command ECS Anywhere support since 2022-01-24

Return type :

None

set_secrets_access ( ) [source]

Method to handle secrets permissions access

set_services_to_services_dependencies ( ) [source]

Method to iterate over each depends_on service set in the family services and add them up

Returns :

set_task_definition ( ) [source]

Function to set or update the task definition

Parameters :

self – the self of services

set_update_containers_priority ( ) [source]

Method to sort out the containers dependencies and create the containers definitions based on the configs.

Return type :

None

static sort_env_vars ( service , environment , secrets = None ) [source]

Sorts env vars. If there are secrets in the list, checks to remove env vars with Name that’d overlap with an existing secret. Favoring secret over environment variable for security, as it’s likely more sensitive.

Return type :

None

static sort_secrets ( service , secrets ) [source]

Sorts secrets by Name

Return type :

None

sort_secrets_env_vars ( ) [source]

Sorts secrets and env vars alphabetically. Removes env vars which would have a Key common to secrets

state_facts ( ) [source]

Function to display facts about the family. Similar to __repr__ but for logging the properties of the ComposeFamily

property task_ephemeral_storage : int

If any service ephemeral storage is defined above, sets the ephemeral storage to the maximum of them. Return 0 if below 21 which is the default “free” Fargate storage space.

validate_compute_configuration_for_task ( settings ) [source]
property want_xray : bool
x_environment_processing ( ) [source]

Checks for each service if x-environment was set

class ecs_composex.ecs.ecs_family. ServiceStack ( name , stack_template , stack_parameters = None , file_name = None , module_name = None , module = None , ** kwargs ) [source]

Bases: ComposeXStack

Class to identify specifically a service stack