ecs_composex.compose.x_resources package

Submodules

ecs_composex.compose.x_resources.api_x_resources module

class ecs_composex.compose.x_resources.api_x_resources. ApiXResource ( name , definition , module , settings ) [source]

Bases: ServicesXResource

Class for Resources that only require API / IAM access to be defined

to_ecs ( settings , modules , root_stack = None , targets_overrides = None ) [source]

Maps API only based resource to ECS Services

Return type :

None

ecs_composex.compose.x_resources.environment_x_resources module

class ecs_composex.compose.x_resources.environment_x_resources. AwsEnvironmentResource ( name , definition , module , settings ) [source]

Bases: XResource

Class for AWS Resources that are used by other AWS Resources. The services do not use these resources directly

Variables :

lookup_only ( bool ) – Whether the XResource should only be looked up.

ecs_composex.compose.x_resources.helpers module

ecs_composex.compose.x_resources.helpers. get_setting_key ( name , settings_dict ) [source]

Allows for flexibility in the syntax, i.e. to make access/Access both valid

Return type :

str

ecs_composex.compose.x_resources.helpers. get_top_stack ( curr_stack , settings ) [source]
ecs_composex.compose.x_resources.helpers. set_lookup_resources ( x_resources ) [source]
Parameters :

x_resources ( list [ XResource ] ) –

Returns :

list of resources to import from Lookup

Return type :

list[ XResource ] x_resources:

ecs_composex.compose.x_resources.helpers. set_new_resources ( x_resources , supports_uses_default = False ) [source]

Function to create a list of new resources. Check if empty resource is supported

Parameters :
  • x_resources ( list [ XResource ] ) –

  • supports_uses_default ( bool ) –

Returns :

list of resources to create

Return type :

list[ XResource ] x_resources:

ecs_composex.compose.x_resources.helpers. set_resources ( settings , resource_class , module ) [source]

Method to define the ComposeXResource for each service. First updates the resources dict

Parameters :

ecs_composex.compose.x_resources.network_x_resources module

class ecs_composex.compose.x_resources.network_x_resources. DatabaseXResource ( name , definition , module , settings ) [source]

Bases: NetworkXResource

Class for network resources that share common properties

Variables :
to_ecs ( settings , modules , root_stack = None ) [source]

Maps a database service to ECS services

Parameters :
Return type :

None

class ecs_composex.compose.x_resources.network_x_resources. NetworkXResource ( name , definition , module , settings ) [source]

Bases: ServicesXResource

Class for resources that need VPC and SecurityGroups to be managed for Ingress

cleanse_external_targets ( ) [source]

Will automatically remove the target families which are set as external

Return type :

None

remove_services_after_family_cleanups ( ) [source]

After the family services have been removed from the target, we ensure that we deal with the services which may or may not be in the targets already

Return type :

None

set_override_subnets ( ) [source]

Updates the subnets to use from default for the given resource

Return type :

None

update_from_vpc ( vpc_stack , settings = None ) [source]

Allows to make adjustments after the VPC Settings have been set

ecs_composex.compose.x_resources.services_resources module

class ecs_composex.compose.x_resources.services_resources. ServicesXResource ( name , definition , module , settings ) [source]

Bases: XResource

Class for XResource that would be linked to services for IAM / Ingress

Variables :
  • families_targets ( list [ tuple ] ) – List of the service targets to associate access with

  • families_scaling ( list [ tuple ] ) – List of the services target to associate scaling with

debug_families_targets ( ) [source]

Method to troubleshoot family and service mapping

static define_service_to_associate ( service_name , family_name , settings ) [source]
Return type :

ecs_composex.compose.compose_services.ComposeService

handle_families_scaling_expansion_dict ( service_name , service , settings ) [source]

Method to list all families and services that are targets of the resource. Allows to implement family and service level association to resource

Return type :

None

handle_families_targets_expansion_dict ( service_name , service_def , settings ) [source]

Method to list all families and services that are targets of the resource. Allows to implement family and service level association to resource

Return type :

None

set_services_scaling ( settings ) [source]

Method to map services and families targets of the services defined. TargetStructure: (family, family_wide, services[], access)

set_services_targets ( settings ) [source]

Method to map services and families targets of the services defined. TargetStructure: (family, family_wide, services[], access)

Return type :

None

set_services_targets_from_dict ( settings ) [source]

Deals with services set as a dict

Return type :

None

set_services_targets_scaling_from_dict ( settings ) [source]

Sets scaling targets to the resource for the defined services in the compose file.

Return type :

None

Module contents

Module to define the ComposeX Resources into a simple object to make it easier to navigate through.

class ecs_composex.compose.x_resources. XResource ( name , definition , module , settings ) [source]

Bases: object

Class to represent each defined resource in the template

Variables :
  • policies_scaffolds ( dict ) – IAM policies template to use to generate IAM policies for the given resource

  • name ( str ) – The name of the resource as defined in compose file

  • definition ( dict ) – The definition of the resource as defined in compose file

  • logical_name ( str ) – Name of the resource to use in CFN template as for export/import

  • requires_vpc ( bool ) – Whether or not the resource requires a VPC to function (i.e. RDS)

add_attribute_to_another_stack ( ext_stack , attribute , settings ) [source]
add_new_output_attribute ( attribute_id , attribute_config , generate_outputs = True ) [source]

Adds a new output to attributes and re-generates all outputs

add_parameter_to_family_stack ( family , settings , parameter ) [source]
Return type :

dict

cloud_control_attributes_mapping_lookup ( resource_type , resource_id , ** kwargs ) [source]

Method to map the resource properties to the CCAPI description :rtype: tuple [ dict , dict ] :return:

property compose_x_arn : str
define_export_name ( output_definition , attribute_parameter ) [source]

Method to define the export name for the resource :return:

property env_var_prefix : str
generate_cfn_mappings_from_lookup_properties ( ) [source]

Sets the .mappings attribute based on the lookup_attributes for CFN purposes

generate_outputs ( ) [source]

Method to create the outputs for XResources

generate_ref_env_var ( target ) [source]

Method to define all the env var of a resource based on its own defined output attributes

Return type :

list

generate_resource_service_env_vars ( target , target_definition ) [source]

Generates env vars based on ReturnValues set for a give service. When the resource is new, adds the parameter to the services stack appropriately.

Return type :

list

get_resource_attribute_value ( parameter , family ) [source]

Finds the value

Return type :

typing.Optional [ tuple ]

init_outputs ( ) [source]

Placeholder method

lookup_resource ( arn_re , native_lookup_function , cfn_resource_type , tagging_api_id , subattribute_key = None , use_arn_for_id = False ) [source]

Method to self-identify properties. It will try to use AWS Cloud Control API if possible, otherwise fallback to using boto3 descriptions functions to create a mapping of the attributes.

property mod_mapping_key : str
property mod_res_key : str
native_attributes_mapping_lookup ( account_id , resource_id , function ) [source]
property parameters : dict
post_processing ( settings ) [source]
property property_to_parameter_mapping
set_attributes_from_mapping ( attribute_parameter ) [source]

Method to define the attribute outputs for lookup resources, which use FindInMap or Ref

Parameters :

attribute_parameter ( ecs_composex.common.cfn_params.Parameter ) – The parameter mapped to the resource attribute

Returns :

The FindInMap setting for mapped resource

set_new_resource_outputs ( output_definition , attribute_parameter ) [source]

Method to define the outputs for the resource when new

set_update_container_env_var ( family , parameter , env_var_name ) [source]

Function that will set or update the value of a given env var from Return value of a resource. If the resource is new, adding the parameter to the top stack If the resource is lookup, point to the mapping.

Return type :

list

property uses_default : bool
validate ( settings , root_stack = None , * args , ** kwargs ) [source]

Function to implement self-validation for the resource and the execution settings.

Parameters :
  • settings

  • root_stack

  • args

  • kwargs

Return type :

None

validate_schema ( name , definition , module_name , module_schema = None ) [source]

JSON Validation of the resources module validation

Return type :

None

ecs_composex.compose.x_resources. validate_input_value ( aws_property_object , property_name , value ) [source]

Validation that input for resource property update if valid

Return type :

typing.Optional [ str ]