ecs_composex.vpc package

Submodules

ecs_composex.vpc.aws_mappings module

Generic mappings for well-known AWS Settings not yet in SSM

ecs_composex.vpc.vpc_aws module

ecs_composex.vpc.vpc_aws. delete_subnet_from_settings ( subnets , subnet_key , vpc_settings ) [source]

Deletes subnets that are not part of the VPC from vpc_settings

Parameters
  • subnets ( list [ dict ] ) –

  • subnet_key ( str ) –

  • vpc_settings ( dict ) –

ecs_composex.vpc.vpc_aws. lookup_x_vpc_settings ( lookup , session ) [source]

Method to set VPC settings from x-vpc

Parameters
  • session ( boto3.session.Session ) –

  • lookup ( dict ) –

Returns

vpc_settings

Return type

dict

ecs_composex.vpc.vpc_aws. validate_subnets_belong_with_vpc ( vpc_settings , subnet_keys , session = None ) [source]

Function to ensure all subnets belong to the identified VPC

Parameters
  • vpc_settings ( dict ) –

  • subnet_keys ( list [ str ] ) –

  • session ( boto3.session.Session ) –

Raises

boto3.client.exceptions

ecs_composex.vpc.vpc_conditions module

ecs_composex.vpc.vpc_maths module

3 Layers subnets calculator for 3-tier VPC

ecs_composex.vpc.vpc_maths. clpow2 ( x ) [source]

Function to return the closest power of two from given x

Parameters

x – Number to look the closest power of two for

Returns

int() closest power of two

ecs_composex.vpc.vpc_maths. cut_per_az ( az_cidr , layers_cidr ) [source]

Subdivide the range per AZ in the region

Parameters
  • az_cidr – CIDR to split

  • layers_cidr – dict() getting updated with layers

Returns

NIL

ecs_composex.vpc.vpc_maths. get_subnet_layers ( cidr , azs ) [source]

Get Subnets layers based on number of AZs

ecs_composex.vpc.vpc_maths. get_subnets ( cidr , azs ) [source]

Get the lists of Subnets CIDRs

ecs_composex.vpc.vpc_maths. nxtpow2 ( x ) [source]

Function to find the next power of two from given x number

Parameters

x – number to look for the next power of two

Returns

next power of two number

ecs_composex.vpc.vpc_params module

Parameters related to the VPC settings. Used by ecs_composex.vpc and others

ecs_composex.vpc.vpc_stack module

Module for VpcStack

class ecs_composex.vpc.vpc_stack. VpcStack ( title , settings , vpc_settings , ** kwargs ) [source]

Bases: ecs_composex.common.stacks.ComposeXStack

Class to create the VPC Stack

ecs_composex.vpc.vpc_stack. add_vpc_to_root ( root_stack , settings ) [source]

Function to figure whether to create the VPC Stack and if not, set the parameters.

Parameters
  • root_stack

  • settings

Returns

vpc_stack

Return type

VpcStack

ecs_composex.vpc.vpc_stack. apply_vpc_settings ( x_settings , root_stack , settings ) [source]
Parameters
Returns

ecs_composex.vpc.vpc_stack. create_new_vpc ( vpc_xkey , settings , default = False ) [source]
ecs_composex.vpc.vpc_stack. create_vpc_mapping ( settings_params ) [source]

Function to create a CFN Mapping to use and assign subnets to substacks

Parameters

settings_params

Returns

ecs_composex.vpc.vpc_stack. define_create_settings ( create_def ) [source]

Function to create the VPC creation settings

Parameters

create_def ( dict ) –

Returns

ecs_composex.vpc.vpc_stack. import_vpc_settings ( vpc_settings ) [source]

Function to import settings set “in-stone” from docker-compose definition

Parameters

vpc_settings ( dict ) –

Returns

settings

Rtype dict

ecs_composex.vpc.vpc_stack. set_subnets_from_use ( subnets_list , vpc_settings , subnets_def ) [source]

ecs_composex.vpc.vpc_subnets module

Functions to add the three VPC layer type subnets:

  • Storage

  • Public

  • App

RTB -> Route Table

Storage subnet type : All subnets use the same RTB, no route to 0.0.0.0/0 Public subnet type: All subnets use the same RTB, route to 0.0.0.0/0 via InternetGateway App subnet type: Each subnet has its own RTB, each RTB points to a different NAT Gateway in its respective AZ

ecs_composex.vpc.vpc_subnets. add_apps_subnets ( template , vpc , az_index , layers , nats , endpoints = None ) [source]

Function to add application/hosts subnets to the VPC

Parameters
  • template – VPC Template()

  • vpc – Vpc() for Ref()

  • az_index ( list ) – index for the AZ (a,b,c ..)

  • nats – list of NatGateway()

Returns

tuple() list of rtb, list of subnets

ecs_composex.vpc.vpc_subnets. add_gateway_endpoint ( service , rtbs , template ) [source]

Function to add a service endpoint for gateways

ecs_composex.vpc.vpc_subnets. add_interface_endpoint ( sg , service , subnets , template ) [source]

Function to add a service endpoint for gateways

ecs_composex.vpc.vpc_subnets. add_public_subnets ( template , vpc , az_index , layers , igw , single_nat ) [source]

Function to add public subnets for the VPC

Parameters
  • layers ( dict ) – layers of subnets

  • igw ( troposphere.ec2.InternetGateway ) – internet gateway to route to

  • single_nat ( boolean ) – whether we should have a single NAT Gateway

  • template ( troposphere.Template ) – VPC Template()

  • vpc ( troposphere.ec2.Template ) – Vpc() for Ref()

  • az_range ( list ) – range for iteration over select AZs

Returns

tuple() list of rtb, list of subnets, list of nats

ecs_composex.vpc.vpc_subnets. add_storage_subnets ( template , vpc , az_index , layers ) [source]

Function to add storage subnets inside the VPC

Parameters
  • layers ( dict ) – VPC layers

  • template ( troposphere.Template ) – VPC Template()

  • vpc ( troposphere.ec2.Vpc ) – Vpc() for Ref()

  • az_index ( list ) – List of AZ Index (a,b,c..)

Returns

tuple() list of rtb, list of subnets

ecs_composex.vpc.vpc_template module

Create the VPC template and its associated resources

ecs_composex.vpc.vpc_template. add_template_outputs ( template , vpc , storage_subnets , public_subnets , app_subnets ) [source]

Function to add outputs / exports to the template

Parameters
  • template – VPC Template()

  • vpc – Vpc() for Ref()

  • storage_subnets – List of Subnet()

  • public_subnets – List of Subnet()

  • app_subnets – List of Subnet()

ecs_composex.vpc.vpc_template. add_vpc_cidrs_outputs ( template , vpc , layers ) [source]

Function to add outputs / exports to the template

Parameters
  • template ( troposphere.Template ) – VPC Template()

  • layers ( dict ) – dict of layers CIDRs to export

ecs_composex.vpc.vpc_template. add_vpc_core ( template , vpc_cidr ) [source]

Function to create the core resources of the VPC and add them to the core VPC template

Parameters
  • template – VPC Template()

  • vpc_cidr – str of the VPC CIDR i.e. 192.168.0.0/24

Returns

tuple() with the vpc and igw object

ecs_composex.vpc.vpc_template. add_vpc_flow ( template , vpc , boundary = None ) [source]

Function to add VPC Flow Log to log VPC

Parameters
  • template ( troposphere.Template ) –

  • vpc – The VPC Object

  • boundary ( str ) –

Module contents