1010from typing import TYPE_CHECKING
1111
1212if TYPE_CHECKING :
13+ from ecs_composex .ecs .ecs_stack import ServiceStack
1314 from ecs_composex .common .settings import ComposeXSettings
1415 from ecs_composex .ecs .ecs_family import ComposeFamily
1516
@@ -75,16 +76,16 @@ def __init__(self, name: str, settings: ComposeXSettings, **kwargs):
7576 stack_template = build_template (
7677 "Services SG for service-to-service communication"
7778 )
78- self .services_mappings : dict [str , ServiceSecurityGroup ] = {}
79+ self .services_mappings : dict [ComposeFamily , ServiceSecurityGroup ] = {}
7980 add_parameters (stack_template , [CLUSTER_NAME , VPC_ID ])
8081 super ().__init__ (name , stack_template , ** kwargs )
8182
8283 for family in settings .families .values ():
8384 sg = ServiceSecurityGroup (family , self )
84- self .services_mappings [family . name ] = sg
85+ self .services_mappings [family ] = sg
8586 add_outputs (stack_template , [sg .output ])
8687
87- def update_vpc_settings (self , vpc_stack : VpcStack ):
88+ def update_vpc_settings (self , vpc_stack : VpcStack , root_stack : ComposeXStack ):
8889 if vpc_stack .vpc_resource and (
8990 vpc_stack .vpc_resource .cfn_resource or vpc_stack .vpc_resource .mappings
9091 ):
@@ -96,3 +97,14 @@ def update_vpc_settings(self, vpc_stack: VpcStack):
9697 self .Parameters .update (
9798 {VPC_ID .title : FindInMap ("Network" , VPC_ID .title , VPC_ID .title )}
9899 )
100+ else :
101+ for family , family_sg in self .services_mappings .items ():
102+ del family .stack .stack_template .parameters [family_sg .parameter .title ]
103+ root_service_stack : ServiceStack = root_stack .stack_template .resources [
104+ family .stack .title
105+ ]
106+ del root_service_stack .properties ["Parameters" ][
107+ family_sg .parameter .title
108+ ]
109+
110+ del root_stack .stack_template .resources [self .name ]
0 commit comments