ecs_composex.compose.compose_services package ¶
Subpackages ¶
- ecs_composex.compose.compose_services.service_image package
-
ecs_composex.compose.compose_services.service_logging package
- Submodules
- ecs_composex.compose.compose_services.service_logging.helpers module
-
Module contents
-
ServiceLogging
-
ServiceLogging.family
-
ServiceLogging.firelens_advanced
-
ServiceLogging.firelens_config
-
ServiceLogging.firelens_shorthands
-
ServiceLogging.log_config
-
ServiceLogging.log_configuration
-
ServiceLogging.log_driver
-
ServiceLogging.log_options
-
ServiceLogging.replace_cw_with_firelens
-
ServiceLogging.service
-
ServiceLogging.set_update_log_configuration()
-
ServiceLogging.uses_firelens
-
-
Submodules ¶
ecs_composex.compose.compose_services.docker_tools module ¶
Docker compose integration related function, wrapping transformation to Container definition.
- ecs_composex.compose.compose_services.docker_tools. find_closest_fargate_configuration ( cpu , ram , as_param_string = False ) [source] ¶
-
Function to get the closest Fargate CPU / RAM Configuration out of a CPU and RAM combination.
- Parameters :
-
-
cpu ( int ) – CPU count for the Task Definition
-
ram ( int ) – RAM in MB for the Task Definition
-
as_param_string ( bool ) – Returns the value as a CFN Fargate Configuration.
-
- Returns :
-
- ecs_composex.compose.compose_services.docker_tools. find_closest_ram_config ( ram , ram_range ) [source] ¶
-
Function to find the closest RAM configuration
- Parameters :
-
-
ram ( int ) – amount of RAM we are trying to match up
-
ram_range ( list ) – List of possible values for Fargate
-
- Returns :
-
the closest amount of RAM.
- Return type :
-
int
- ecs_composex.compose.compose_services.docker_tools. handle_bytes_units ( value , factor ) [source] ¶
-
Function to handle KB use-case
- ecs_composex.compose.compose_services.docker_tools. import_time_values_to_seconds ( time_string , as_tuple = False , maximum = None ) [source] ¶
-
Function to parse strings with h/m/s
- Parameters :
-
-
time_string ( str ) –
-
as_tuple ( bool ) – Whether or not return a tuple (hours, minutes, seconds)
-
- Returns :
-
The number of seconds or tuple of time breakdown as ints
- Return type :
-
int, tuple(int, int, int)
ecs_composex.compose.compose_services.env_files_helpers module ¶
- ecs_composex.compose.compose_services.env_files_helpers. add_envfiles_bucket_iam_access ( env_files , family , settings ) [source] ¶
- ecs_composex.compose.compose_services.env_files_helpers. upload_services_env_files ( family , settings ) [source] ¶
-
Method to go over each service and if settings are to upload files to S3, will create objects and update the container definition for env_files accordingly.
- Parameters :
-
-
family –
-
settings ( ecs_composex.common.settings.ComposeXSettings ) –
-
- Return type :
-
None
- Returns :
-
ecs_composex.compose.compose_services.helpers module ¶
- ecs_composex.compose.compose_services.helpers. define_ingress_mappings ( service_ports ) [source] ¶
-
Function to create a mapping of sources for a common target
- Return type :
-
dict
- ecs_composex.compose.compose_services.helpers. define_string_interpolation ( var_value ) [source] ¶
-
Function to determine whether an env variable string should use Sub.
- Parameters :
-
var_value ( str ) – The env var string as defined in compose file
- Returns :
-
String as is or Sub for interpolation
- Return type :
-
str
- ecs_composex.compose.compose_services.helpers. extend_container_envvars ( container , env_vars , replace = False ) [source] ¶
-
Extends the container environment variables with new ones to add. If not already set, defines.
- Return type :
-
None
- ecs_composex.compose.compose_services.helpers. extend_container_secrets ( container , secret ) [source] ¶
-
Add secrets to a Container definition
- ecs_composex.compose.compose_services.helpers. import_env_variables ( environment ) [source] ¶
-
Function to import Docker compose env variables into ECS Env Variables
- Parameters :
-
environment ( dict ) – Environment variables as defined on the ecs_service definition
- Returns :
-
list of Environment
- Return type :
-
list<troposphere.ecs.Environment>
- ecs_composex.compose.compose_services.helpers. import_secrets ( template , service , container , settings ) [source] ¶
-
Function to import secrets from compose-x and map those to AWS Secrets in Secrets Manager
- ecs_composex.compose.compose_services.helpers. set_environment_dict_from_list ( environment ) [source] ¶
-
Transforms a list of string with a
key=value
into a dict of key/value- Return type :
-
dict
[str
,str
]
- ecs_composex.compose.compose_services.helpers. set_validate_environment ( container ) [source] ¶
-
Validates that the environment property of the container definition is valid. If is NoValue
- Return type :
-
None
ecs_composex.compose.compose_services.kernel_options_helpers module ¶
- ecs_composex.compose.compose_services.kernel_options_helpers. define_kernel_options ( service ) [source] ¶
-
Define and return the kernel option settings for cap_add and cap_drop
- ecs_composex.compose.compose_services.kernel_options_helpers. set_add_capacities ( service , add_key , valid , cap_adds , all_adds , fargate ) [source] ¶
-
Method to set the kernel capacities to add
- Parameters :
-
-
add_key ( str ) –
-
valid ( list ) –
-
cap_adds ( list ) –
-
all_adds ( list ) –
-
fargate ( list ) –
-
- ecs_composex.compose.compose_services.kernel_options_helpers. set_drop_capacities ( service , drop_key , valid , cap_adds , all_adds , all_drops , fargate ) [source] ¶
-
Set the drop kernel capacities
- Parameters :
-
-
drop_key ( str ) –
-
valid ( list ) –
-
cap_adds ( list ) –
-
all_adds ( list ) –
-
all_drops ( list ) –
-
fargate ( list ) –
-
Module contents ¶
Module to import the services defined in compose files and import / transform the settings into Compose-X usable properties
- class ecs_composex.compose.compose_services. ComposeService ( name , definition , volumes = None , secrets = None , image_param = None ) [source] ¶
-
Bases:
object
Class to represent a docker-compose singleton service
- Variables :
-
-
container_name ( str ) – name of the container to use in definitions
-
logging ( ecs_composex.compose.compose_services.service_logging.ServiceLogging ) –
-
image ( ServiceImage ) –
-
- property capacity_provider_strategy ¶
- property command ¶
- property compose_x_arn : str ¶
- property container_name : str ¶
- property container_start_condition : str ¶
- property cpu_amount : Union [ int , Ref ] ¶
- define_port_mappings ( ) [source] ¶
-
Define the list of port mappings to use for either AWS VPC deployments or else (bridge etc). Not in use atm as AWS VPC is made mandatory
- Return type :
-
list
- property definition ¶
- property deploy_labels ¶
- property ecs_healthcheck : Union [ HealthCheck , AWSHelperFn ] ¶
-
If HealthCheck already set ContainerDefinition and value is “None” but service.healtheck defined, define HealthCheck() from service.healthcheck. Elif already defined and not “None”, return current value
- ecs_plugin_aws_keys = [('x-aws-role', <class 'dict'>), ('x-aws-policies', <class 'list'>), ('x-aws-autoscaling', <class 'dict'>), ('x-aws-pull_credentials', <class 'str'>), ('x-aws-logs_retention', <class 'int'>), ('x-aws-min_percent', <class 'int'>), ('x-aws-max_percent', <class 'int'>)] ¶
- property ecs_user : Union [ str , AWSHelperFn ] ¶
- property entrypoint ¶
- property env_files : list ¶
-
Method to list all the env files and check the files are found and available.
- property ephemeral_storage : int ¶
- property families ¶
- property family : ComposeFamily ¶
- property family_hostname : str ¶
- handle_expose_ports ( aws_vpc_mappings ) [source] ¶
-
Import the expose ports to AWS VPC Mappings
- Parameters :
-
aws_vpc_mappings ( list [ troposphere.ecs.PortMapping ] ) – List of ECS Port Mappings defined from ports[]
- property healthcheck ¶
- property is_essential : bool ¶
-
In order of absolutes * If only 1 container in service, it must be essential * If user defined value (bool) and start condition is not SUCCESS or COMPLETE, then user defined * If not user defined value (None) and start condition is SUCCESS or COMPLETE, then it cannot be essential,
as it is expected to shutdown
- property kernel_properties : KernelCapabilities ¶
- property launch_type : Optional [ str ] ¶
- property logical_name : str ¶
- main_key = 'services' ¶
- property memory_limit ¶
- property memory_reservations ¶
- property networks ¶
- property replicas ¶
- property resources ¶
- property runtime_architecture ¶
- property runtime_os_family ¶
- set_container_definition ( ) [source] ¶
-
Function to define the container definition matching the service definition
- set_x_credentials_secret ( key ) [source] ¶
-
Method that will set the secret associated to the service to retrieve the docker image if defined through x-aws-pull_credentials
- property shm_size ¶
-
Method to import and determine SHM SIZE
- property stop_grace_period ¶
-
Method to import and determine StopTimeout
- property sysctls ¶
-
Method to define the SystemControls
- property tmpfs ¶
-
Method to define the tmpfs settings
- property ulimits : Union [ list , Ref ] ¶
-
Set the ulimits
- property update_config ¶
- property user_define_essential : Union [ None , bool ] ¶
-
Allows user to override whether a container is essential or not. By default, in absence of the label, service is considered essential as it might be the only one in the family
- property working_dir ¶
- property x_iam : dict ¶