def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): """ Init method :param str title: :param ecs_composex.common.settings.ComposeXSettings settings: :param kwargs: """ set_resources(settings, CodeProfiler, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: if not keyisset(module.mapping_key, settings.mappings): settings.mappings[module.mapping_key] = {} define_lookup_profile_mappings( settings.mappings[module.mapping_key], lookup_resources, settings) new_resources = set_new_resources(x_resources, False) if new_resources: stack_template = create_root_template(new_resources, module.res_key) super().__init__(title, stack_template, **kwargs) else: self.is_void = True for resource in settings.compose_content[module.res_key].values(): resource.stack = self
def __init__( self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs ): set_resources(settings, Elbv2, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) new_resources = set_new_resources(x_resources, True) if lookup_resources: warnings.warn( f"{module.res_key} - Lookup not supported. You can only create new resources." ) if not new_resources: self.is_void = True return stack_template = init_elbv2_template() lb_input = { VPC_ID.title: Ref(VPC_ID), APP_SUBNETS.title: Ref(APP_SUBNETS), PUBLIC_SUBNETS.title: Ref(PUBLIC_SUBNETS), } for resource in new_resources: resource.set_lb_definition() resource.sort_alb_ingress(settings, stack_template) super().__init__(title, stack_template, stack_parameters=lb_input, **kwargs) for resource in new_resources: resource.stack = self
def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): """ :param str title: Name of the stack :param ecs_composex.common.settings.ComposeXSettings settings: :param dict kwargs: """ set_resources(settings, Queue, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: resolve_lookup(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, True) if new_resources: template = build_template( "SQS template generated by ECS Compose-X") if lookup_resources: add_update_mapping(template, module.mapping_key, settings.mappings[module.mapping_key]) super().__init__(title, stack_template=template, **kwargs) render_new_queues(settings, new_resources, x_resources, self, template) else: self.is_void = True for resource in settings.compose_content[module.res_key].values(): resource.stack = self
def __init__(self, title: str, settings: ComposeXSettings, module: XResourceModule, **kwargs): """ :param str title: :param ecs_composex.common.settings.ComposeXSettings settings: :param dict kwargs: """ set_resources(settings, UserPool, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: resolve_lookup(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, False) if new_resources: LOG.error( f"{module.res_key} does not support new resources creation yet." ) stack_template = build_template( f"Root stack to manage {module.mod_key}") super().__init__(title, stack_template, **kwargs) self.is_void = True else: self.is_void = True for resource in x_resources: resource.stack = self
def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): """ Method to initialize the XStack for Events :param str title: title for the stack :param ecs_composex.common.settings.ComposeXSettings settings: Execution settings :param dict kwargs: """ set_resources(settings, Rule, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: warnings.warn( f"{module.res_key} does not support Lookup/Use. You can only create new resources" ) new_resources = set_new_resources(x_resources, False) if new_resources: stack_template = build_template( "Events rules for ComposeX", [CLUSTER_NAME, FARGATE_VERSION], ) super().__init__(title, stack_template, **kwargs) create_events_template(self, settings, new_resources) else: self.is_void = True
def __init__( self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs ): set_resources(settings, Rds, module) x_resources = settings.compose_content[module.res_key].values() new_resources = set_new_resources(x_resources, True) lookup_resources = set_lookup_resources(x_resources) if new_resources: stack_template = build_template( "Root stack for RDS DBs", [VPC_ID, STORAGE_SUBNETS] ) super().__init__(title, stack_template, **kwargs) generate_rds_templates(stack_template, new_resources, settings) self.mark_nested_stacks() else: self.is_void = True for resource in settings.compose_content[module.res_key].values(): resource.stack = self if lookup_resources and module.mapping_key not in settings.mappings: settings.mappings[module.mapping_key] = {} for resource in lookup_resources: if keyisset("cluster", resource.lookup): resource.lookup_resource( RDS_DB_CLUSTER_ARN_RE, get_db_cluster_config, CfnDBCluster.resource_type, "rds:cluster", "cluster", ) elif keyisset("db", resource.lookup): resource.lookup_resource( RDS_DB_INSTANCE_ARN_RE, get_db_instance_config, CfnDBInstance.resource_type, "rds:db", "db", ) else: raise KeyError( f"{resource.module.res_key}.{resource.name} - " "You must specify the cluster or instance to lookup" ) if keyisset("secret", resource.lookup): lookup_rds_secret(resource, resource.lookup["secret"]) resource.generate_cfn_mappings_from_lookup_properties() resource.generate_outputs() settings.mappings[module.mapping_key].update( {resource.logical_name: resource.mappings} )
def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, Stream, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: resolve_lookup(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, True) if new_resources: stack_template = create_streams_template(new_resources, settings) super().__init__(title, stack_template, **kwargs) else: self.is_void = True for resource in x_resources: resource.stack = self
def __init__(self, name, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, Efs, module) x_resources = settings.compose_content[module.res_key].values() new_resources = set_new_resources(x_resources, False) lookup_resources = set_lookup_resources(x_resources) if new_resources: stack_template = create_efs_stack(settings, new_resources) super().__init__(name, stack_template, **kwargs) else: self.is_void = True if lookup_resources: warnings.warn( f"{module.res_key} - Lookup not supported. You can only create new resources at the moment" ) for resource in settings.compose_content[module.res_key].values(): resource.stack = self
def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, Table, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: resolve_lookup(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, False) if new_resources: stack_template = build_template( "Root template for DynamoDB tables") super().__init__(title, stack_template, **kwargs) create_dynamodb_template(new_resources, stack_template, self) else: self.is_void = True for resource in x_resources: if resource.lookup: resource.stack = self
def __init__(self, title: str, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, Bucket, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: if not keyisset(module.mapping_key, settings.mappings): settings.mappings[module.mapping_key] = {} define_bucket_mappings(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, True) if new_resources: stack_template = build_template( f"Root template for {settings.name}.s3") super().__init__(module.mapping_key, stack_template, **kwargs) create_s3_template(new_resources, stack_template) else: self.is_void = True for resource in settings.compose_content[module.res_key].values(): resource.stack = self
def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, OpenSearchDomain, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) new_resources = set_new_resources(x_resources, True) if new_resources: stack_template = build_template("Root template for OpenSearch", [VPC_ID, STORAGE_SUBNETS]) super().__init__(title, stack_template, **kwargs) create_new_domains(new_resources, self) else: self.is_void = True if lookup_resources: if not keyisset(module.mapping_key, settings.mappings): settings.mappings[module.mapping_key] = {} create_opensearch_mappings(lookup_resources, settings) for resource in settings.compose_content[module.res_key].values(): resource.stack = self
def __init__(self, name, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, Alarm, module) x_resources = settings.compose_content[module.res_key].values() new_resources = set_new_resources(x_resources, False) lookup_resources = set_lookup_resources(x_resources) if new_resources: template = build_template( "Root stack for Alarms created via Compose-X") super().__init__(name, stack_template=template, **kwargs) create_alarms(template, new_resources) else: self.is_void = True if lookup_resources: warnings.warn( f"{module.res_key} - Lookup and Use are not supported. " "You can only create new resources") for resource in x_resources: resource.stack = self
def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, SsmParameter, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: resolve_lookup(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, False) if new_resources: template = build_template( "Parent template for SSM in ECS Compose-X") super().__init__(module.mapping_key, stack_template=template, **kwargs) render_new_parameters(new_resources, self) else: self.is_void = True for resource in settings.compose_content[module.res_key].values(): resource.stack = self
def __init__( self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs ): set_resources(settings, Topic, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: create_sns_mappings(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, True) if not new_resources: self.is_void = True else: template = build_template( f"{module.res_key} - Compose-X Generated template" ) generate_sns_templates(settings, new_resources, self, template) super().__init__(module.mapping_key, stack_template=template, **kwargs) for resource in x_resources: resource.stack = self
def __init__( self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs ): set_resources(settings, CacheCluster, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: if not keyisset(module.res_key, settings.mappings): settings.mappings[module.res_key] = {} create_lookup_mappings( settings.mappings[module.res_key], lookup_resources, settings ) new_resources = set_new_resources(x_resources, False) if new_resources: stack_template = create_root_template(new_resources) super().__init__(title, stack_template, **kwargs) else: self.is_void = True for resource in x_resources: resource.stack = self
def __init__(self, title, settings: ComposeXSettings, module: XResourceModule, **kwargs): set_resources(settings, KmsKey, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) new_resources = set_new_resources(x_resources, True) if new_resources: stack_template = build_template("Root template for KMS") super().__init__(title, stack_template, **kwargs) create_kms_template(stack_template, new_resources, self) else: self.is_void = True if lookup_resources: if not keyisset(module.mapping_key, settings.mappings): settings.mappings[module.mapping_key] = {} for resource in lookup_resources: resource.lookup_resource(KMS_KEY_ARN_RE, get_key_config, Key.resource_type, "kms:key") settings.mappings[module.mapping_key].update( {resource.logical_name: resource.mappings}) for resource in settings.compose_content[module.res_key].values(): resource.stack = self
def __init__( self, name: str, settings: ComposeXSettings, module: XResourceModule, **kwargs ): """ :param str name: :param ecs_composex.common.settings.ComposeXSettings settings: :param dict kwargs: """ set_resources(settings, Certificate, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) new_resources = set_new_resources(x_resources, False) if new_resources: stack_template = build_template("ACM Certificates created from x-acm") super().__init__(name, stack_template, module=module, **kwargs) define_acm_certs(new_resources, self) else: self.is_void = True if lookup_resources: resolve_lookup(lookup_resources, settings, module) self.module_name = module.mod_key for resource in x_resources: resource.stack = self
def __init__( self, name: str, settings: ComposeXSettings, module: XResourceModule, **kwargs ): """ :param str name: :param ecs_composex.common.settings.ComposeXSettings settings: :param dict kwargs: """ self.x_to_x_mappings = [] self.x_resource_class = HostedZone set_resources(settings, HostedZone, module) x_resources = settings.compose_content[module.res_key].values() lookup_resources = set_lookup_resources(x_resources) if lookup_resources: resolve_lookup(lookup_resources, settings, module) new_resources = set_new_resources(x_resources, False) if new_resources: stack_template = build_template(self.stack_title) super().__init__(module.mapping_key, stack_template, **kwargs) else: self.is_void = True for resource in x_resources: resource.stack = self
def __init__( self, name: str, settings: ComposeXSettings, module: XResourceModule, **kwargs ): """ :param str name: :param ecs_composex.common.settings.ComposeXSettings settings: :param dict kwargs: """ set_resources(settings, PrivateNamespace, module) x_resources = settings.compose_content[module.res_key].values() detect_duplicas(x_resources) lookup_resources = set_lookup_resources(x_resources) new_resources = set_new_resources(x_resources, supports_uses_default=True) for resource in x_resources: resource.stack = self if new_resources: stack_template = build_template(self._title) super().__init__(module.mapping_key, stack_template, **kwargs) define_new_namespace(new_resources, stack_template) else: self.is_void = True if lookup_resources: resolve_lookup(lookup_resources, settings, module) self.module_name = module.mod_key