ECS-ComposeX

ecs_composex package

Subpackages

Submodules

ecs_composex.cli module

Console script for ecs_composex.

class ecs_composex.cli.ArgparseHelper(option_strings, dest='==SUPPRESS==', default='==SUPPRESS==', help=None)[source]

Bases: argparse._HelpAction

Used to help print top level ‘–help’ arguments from argparse when used with subparsers

Usage: parser = argparse.ArgumentParser(add_help=False) parser.add_argument(‘-h’, ‘–help’, action=ArgparseHelper,

help=’show this help message and exit’)

ecs_composex.cli.main()[source]

Main entry point for CLI :return: status code

ecs_composex.cli.main_parser()[source]

Console script for ecs_composex.

ecs_composex.ecs_composex module

Main module to generate a full stack with VPC, Cluster, Compute, Services and all X- AWS resources.

ecs_composex.ecs_composex.add_compute(root_template, settings, vpc_stack)[source]

Function to add Cluster stack to root one. If any of the options related to compute resources are set in the CLI then this function will generate and add the compute template to the root stack template

Parameters
  • root_template (troposphere.Template) – the root template

  • vpc_stack (ComposeXStack) – the VPC stack if any to pull the attributes from

  • settings (ComposeXSettings) – The settings for execution

Returns

compute_stack, the Compute stack

Return type

ComposeXStack

ecs_composex.ecs_composex.add_x_resources(root_template, settings, vpc_stack=None)[source]

Function to add each X resource from the compose file

ecs_composex.ecs_composex.apply_x_configs_to_ecs(settings, root_template, services_stack, services_families, **kwargs)[source]

Function that evaluates only the x- resources of the root template and iterates over the resources. If there is an implemented module in ECS ComposeX for that resource to map to the ECS Services, it will execute the function available in the module to apply defined settings to the services stack.

Parameters
ecs_composex.ecs_composex.apply_x_to_x_configs(root_template, settings)[source]

Function to iterate over each XStack and trigger cross-x resources configurations functions

Parameters
  • root_template (troposphere.Template) – the ECS ComposeX root template

  • settings (ComposeXSettings) – The execution settings

Returns

ecs_composex.ecs_composex.create_services(root_stack, settings, vpc_stack, dns_params, create_cluster)[source]

Function to add the microservices root stack

Parameters
  • root_stack (ComposeXStack) – ComposeX root stack

  • settings (ComposeXSettings) – The settings for execution

  • vpc_stack (ComposeXStack) – The VPC Stack

  • dns_params (dict) – DNS Parameters for the execution

  • create_cluster (bool) – Indicates whether the cluster is created from this stack

ecs_composex.ecs_composex.generate_full_template(settings)[source]

Function to generate the root root_template

Parameters

settings (ecs_composex.common.settings.ComposeXSettings) – The settings for the execution

Return root_template

Template, params

Return type

root_template, list

ecs_composex.ecs_composex.get_mod_class(module_name)[source]

Function to get the XModule class for a specific ecs_composex module

Parameters

module_name (str) – Name of the x-module we are looking for.

Returns

the_class, maps to the main class for the given x-module

ecs_composex.ecs_composex.get_mod_function(module_name, function_name)[source]

Function to get function in a given module name from function_name

Parameters
  • module_name (str) – the name of the module in ecs_composex to find and try to import

  • function_name (str) – name of the function to try to get

Returns

function, if found, from the module

Return type

function

ecs_composex.ecs_composex.get_vpc_id(vpc_stack)[source]

Function to add CloudMap to VPC

Parameters

vpc_stack (ComposeXStack) – VpcStack

ecs_composex.ecs_composex.init_root_template()[source]

Function to initialize the root template

Returns

template

Return type

troposphere.Template

ecs_composex.resource_permissions module

Module to handle permissions from x-resource to ECS service

ecs_composex.resource_permissions.add_iam_policy_to_service_task_role(service_template, resource, perms, access_type, service_name, family_wide)[source]

Function to expand the ECS Task Role policy with the permissions for the resource :param troposphere.Template service_template: :param resource: :param perms: :param access_type: :param service_name: :param family_wide: :return:

ecs_composex.resource_permissions.apply_iam_based_resources(resource, services_families, services_stack, res_root_stack, perms, nested=False)[source]

Function to assign resource to services stack

Parameters
Raises

KeyError – if the service name is not a listed service in docker-compose.

ecs_composex.resource_settings module

Module to handle resource settings definition to containers.

ecs_composex.resource_settings.generate_export_strings(res_name, attribute)[source]

Function to generate the SSM and CFN import/export strings Returns the import in a tuple

Parameters
  • res_name (str) – name of the queue as defined in ComposeX File

  • attribute (str|Parameter) – The attribute to use in Import Name.

Returns

ImportValue for CFN

Return type

ImportValue

ecs_composex.resource_settings.generate_resource_permissions(resource_name, policies, attribute, arn=None)[source]

Function to generate IAM permissions for a given x-resource. Returns the mapping of these for the given resource.

Parameters
  • resource_name (str) – The name of the resource

  • attribute (str) – the attribute of the resource we are using for Import

  • policies (dict) – the policies associated with the x-resource type.

  • arn (str) – The ARN of the resource if already looked up.

Returns

dict of the IAM policies associated with the resource.

Rtype dict

Module contents

Top-level package for ECS ComposeX.