ecs_composex.rds package

Submodules

ecs_composex.rds.rds_aws module

Module to scan and find the DB and Secret for Lookup of x-rds

ecs_composex.rds.rds_aws. handle_secret ( lookup , db_config , session ) [source]

Function to identify and update definition with secret if defined and found

Parameters
  • lookup ( dict ) – The Lookup definition for DB

  • session ( boto3.session.Session ) – Boto3 session for clients

  • db_config ( dict ) –

Returns

ecs_composex.rds.rds_aws. lookup_rds_resource ( lookup , session ) [source]

Function to find the DB in AWS account

Parameters
  • lookup ( dict ) – The Lookup definition for DB

  • session ( boto3.session.Session ) – Boto3 session for clients

Returns

ecs_composex.rds.rds_aws. patch_db_vs_cluster ( db_config , res_type ) [source]

Function to match the difference in structure for rds:db and rds:cluster

Parameters
  • db_config ( dict ) – The DB config retrieved

  • res_type ( str ) – The RDS resource type, db|cluster

Returns

ecs_composex.rds.rds_aws. return_db_config ( db_arn , session , res_type ) [source]

Function to retrieve the DB information we need for services integration :param db_arn: :param session: :param res_type: :type db_arn: str :type session: boto3.session.Session :type res_type: str :return: the DB details

ecs_composex.rds.rds_aws. validate_rds_lookup ( db_name , lookup ) [source]

Function to validate the lookup settings are correct :param db_name: The composex resource :type db_name: str :param lookup: The DB Lookup property :type lookup: dict :return: :raises: KeyError

ecs_composex.rds.rds_aws. validate_rds_settings ( lookup_properties ) [source]

Function to validate RDS properties for lookup :param dict lookup_properties: :raises: KeyError, TypeError

ecs_composex.rds.rds_conditions module

ecs_composex.rds conditions for CFN. Allows to implement conditional logic in native CFN format.

ecs_composex.rds.rds_db_template module

RDS DB template generator

ecs_composex.rds.rds_db_template. add_db_instances_for_cluster ( db_template , db ) [source]

Function to add DB instances for a RDS Cluster

Parameters
ecs_composex.rds.rds_db_template. add_db_outputs ( db_template , db ) [source]

Function to add outputs to the DB template

Parameters
ecs_composex.rds.rds_db_template. add_db_sg ( template , db_name ) [source]

Function to add a Security group for the database

Parameters
  • db_name ( str ) – Name of the database as defined in compose file

  • template ( troposphere.Template ) – template to add the sg to

ecs_composex.rds.rds_db_template. add_default_cluster_definition ( db ) [source]

Function to add the cluster to the template

Parameters

db ( ecs_composex.rds.rds_stack.Rds ) – The Rds resource

Returns

cluster

Return type

troposphere.rds.DBCluster

ecs_composex.rds.rds_db_template. add_default_instance_definition ( db , for_cluster = False ) [source]

Function to add DB Instance(s)

Parameters
ecs_composex.rds.rds_db_template. add_instances_from_parameters ( db_template , db ) [source]

Function to go over each Instance defined in parameters

Parameters
Raises

TypeError

ecs_composex.rds.rds_db_template. add_parameter_group ( template , db ) [source]

Function to create a parameter group which uses the same values as default which can later be altered

Parameters
  • template ( troposphere.Template ) – the RDS template

  • db ( ecs_composex.common.compose_resources.Rds ) – the db object as imported from Docker composeX file

ecs_composex.rds.rds_db_template. create_db_subnet_group ( template , db , subnets = None ) [source]

Function to create a subnet group

Parameters
  • template ( troposphere.Template ) – the template to add the subnet group to.

  • subnets – The subnets to use.

Returns

group, the DB Subnets Group

Return type

troposphere.rds.DBSubnetGroup

ecs_composex.rds.rds_db_template. create_from_parameters ( db_template , db ) [source]

Function to create the RDS resources from MacroParameters when Properties are not set.

Parameters
Returns

ecs_composex.rds.rds_db_template. create_from_properties ( db_template , db ) [source]

Function to create RDS resources based on the Properties defined in Compose files. It will try to identify what type of resource (Cluster or Instance) is defined based on the properties that were given. If not capable, falls back to using MacroParameters, and if not, raises exception

Parameters
Raises

RuntimeError

ecs_composex.rds.rds_db_template. determine_resource_type ( db_name , properties ) [source]

Function to determine if the properties are the ones of a DB Cluster or DB Instance. By default it will assume Cluster if cannot conclude that it is a DB Instance

Parameters
  • db_name ( str ) –

  • properties ( dict ) –

Returns

ecs_composex.rds.rds_db_template. generate_database_template ( db , settings ) [source]

Function to generate the database template :param ecs_composex.rds.rds_stack.Rds db: The database object

Returns

db_template

Return type

troposphere.Template

ecs_composex.rds.rds_db_template. init_database_template ( db ) [source]

Function to initialize the DB Template

Parameters

db – The DB definition

Returns

template

Return type

troposphere.Template

ecs_composex.rds.rds_db_template. override_set_properties ( props , db ) [source]

Function to override secrets parameters from the rds properties

ecs_composex.rds.rds_db_template. set_parameters_groups_from_macro_parameters ( db , template ) [source]

Function to set the DB parameters group if ParametersGroups is set on MacroParameters

ecs_composex.rds.rds_ecs module

Module to provide services with access to the RDS databases.

ecs_composex.rds.rds_ecs. create_lookup_mappings ( mappings , lookup_dbs , settings ) [source]

Function to create the RDS mappings to add to services templates

Parameters
ecs_composex.rds.rds_ecs. create_rds_db_config_mapping ( db , db_config ) [source]
Parameters
  • db

  • db_config

Returns

ecs_composex.rds.rds_ecs. handle_import_dbs_to_services ( db , rds_mapping , target , mapping_name ) [source]

Function to map the Looked up DBs (DocDB and RDS) to the services.

Parameters
  • db – The DB resource

  • rds_mapping ( dict ) –

  • target ( tuple ) –

  • mapping_name ( str ) –

ecs_composex.rds.rds_ecs. import_dbs ( db , db_mappings , mapping_name ) [source]

Function to go over each service defined in the DB and assign found DB settings to service

Parameters
Returns

ecs_composex.rds.rds_ecs. rds_to_ecs ( rds_dbs , services_stack , res_root_stack , settings ) [source]

Function to apply onto existing ECS Templates the various settings

Parameters
Returns

ecs_composex.rds.rds_features module

Module to handle RDS Features definition

ecs_composex.rds.rds_features. add_rds_features ( settings , stack , db , features , db_template , boundary ) [source]

Function to add AssociatedRoles and Features if not already defined in the DB properties for that feature.

ecs_composex.rds.rds_features. apply_extra_parameters ( settings , stack , db , db_template ) [source]

Function to add extra parameters set in MacroParameters post creation of the DB resource from properties

Parameters
Returns

ecs_composex.rds.rds_features. define_associated_roles ( db ) [source]

Function to define the AssociatedRoles, either present or empty :param ecs_composex.rds.rds_stack.RdsDb db: :return: the list of Associated Roles :rtype: list

ecs_composex.rds.rds_features. validate_features_content ( data ) [source]

Function to ensure the data given in compose file is valid for S3/MacroParameters/IamAccess

Parameters
  • allowed_keys ( dict ) –

  • data ( dict ) –

Returns

ecs_composex.rds.rds_features. validate_rds_features ( features_list , db_family ) [source]

Function to validate the features listed are supported by the given family.

Parameters
  • features_list

  • db_family

Returns

ecs_composex.rds.rds_features_define module

Module to define and match RDS Features to other AWS resources.

ecs_composex.rds.rds_features_define. define_s3_bucket_arns ( settings , stack , db , config , db_template ) [source]

Function to define the IAM Policy for S3Import access

Parameters
  • settings

  • db

  • config

  • db_template

  • subconfig

Returns

ecs_composex.rds.rds_features_define. define_s3_export_feature_policy ( settings , stack , db , config , db_template ) [source]

Function to define the IAM Policy for S3Import access

Parameters
  • settings

  • db

  • config

  • db_template

  • subconfig

Returns

ecs_composex.rds.rds_features_define. define_s3_import_feature_policy ( settings , stack , db , config , db_template ) [source]

Function to define the IAM Policy for S3Import access

Parameters
  • settings

  • db

  • config

  • db_template

  • subconfig

Returns

ecs_composex.rds.rds_features_define. get_s3_bucket_arn_from_resource ( db_template , stack , resource ) [source]
ecs_composex.rds.rds_features_define. import_bucket_from_arn ( bucket ) [source]

Function to import a bucket defined by its ARN, supports to detect the path in bucket for objects

Parameters

bucket ( str ) –

Returns

the bucket ARN to use

Return type

str

ecs_composex.rds.rds_features_define. import_raw_bucket_name ( bucket ) [source]

Function to import and define a bucket ARN from bucket name alone and support for path to be defined :param str bucket: :return: the bucket ARN :rtype: Sub

ecs_composex.rds.rds_features_define. set_from_x_s3 ( settings , stack , db , db_template , bucket_name ) [source]

Function to link the RDS DB to a Bucket defined in x-s3

Parameters
  • settings

  • db

  • db_template

  • bucket_name ( str ) –

Returns

ecs_composex.rds.rds_parameter_groups_helper module

Helper to generate default parameter group settings from engine name and version

ecs_composex.rds.rds_parameter_groups_helper. get_db_cluster_engine_parameter_group_defaults ( engine_family ) [source]

Returns a dict of all the parameter group parameters and default values

Parm str engine_family

Engine family we are getting the cluster settings for, i.e. aurora-mysql5.7

ecs_composex.rds.rds_parameter_groups_helper. get_family_from_engine_version ( engine_name , engine_version , session = None , client = None ) [source]

Function to get the engine family from engine name and version :param client: override client for boto3 call :type client: boto3.client :param session: override session for boto3 client :type session: boto3.session.Session :param engine_name: engine name, ie. aurora-mysql :type engine_name: str :param engine_version: engine version, ie. 5.7.12 :type engine_version: str :return: engine_family :rtype: str

ecs_composex.rds.rds_parameter_groups_helper. get_family_settings ( db_family ) [source]

Function to get the DB family settings :param str db_family: The DB family :return: db settings or None :rtype: None or dict

ecs_composex.rds.rds_params module

ecs_composex.rds parameters.

This is a crucial part as all the titles, marked _T are string which are then used the same way across all imports, which gives consistency for CFN to use the same names, which it heavily relies onto.

You can change the names values so you like so long as you keep it Alphanumerical [a-zA-Z0-9]

ecs_composex.rds.rds_stack module

Module to handle AWS RDS CFN Templates creation

class ecs_composex.rds.rds_stack. Rds ( name , definition , module_name , settings ) [source]

Bases: ecs_composex.common.compose_resources.XResource

Class to represent a RDS DB

init_outputs ( ) [source]

Method to init the RDS Output attributes

subnets_param = <ecs_composex.common.cfn_params.Parameter object>
class ecs_composex.rds.rds_stack. XStack ( title , settings , ** kwargs ) [source]

Bases: ecs_composex.common.stacks.ComposeXStack

Class to handle ECS root stack specific settings

add_xdependencies ( root_stack , settings ) [source]

Method to handle RDS to other x- resources links.

Parameters
Returns

ecs_composex.rds.rds_template module

Main module template to generate the RDS Root template and all stacks according to x-rds settings

class ecs_composex.rds.rds_template. RdsDbStack ( name , stack_template , db , ** kwargs ) [source]

Bases: ecs_composex.common.stacks.ComposeXStack

Class to represent a RDS Stack

ecs_composex.rds.rds_template. add_db_stack ( root_template , db , settings ) [source]

Function to add the DB stack to the root stack

Parameters
ecs_composex.rds.rds_template. generate_rds_templates ( root_tpl , new_dbs , settings ) [source]

Function to generate the RDS root template for all the DBs defined in the x-rds section of the compose file

Parameters

Module contents

Module to handle AWS RDS CFN Templates creation