@@ -130,13 +130,9 @@ def create_color_task_definition(self, color, environment_name):
130130 )
131131 return task_definition
132132 # This function creates the ECS service for each corresponding color
133- def create_color_service (self , color , namespace , taskdef , ):
133+ def create_color_service (self , color , namespace , taskdef , imported_vpc ):
134134 environment_name = "appmesh-env"
135- vpc_id = core .Fn .import_value (f"{ environment_name } :VPCID" )
136-
137- availability_zones = core .Fn .split (',' , f"{ environment_name } :VpcAvailabilityZones" )
138- private_subnet_ids = core .Fn .split (',' , core .Fn .import_value (f"{ environment_name } :MyPrivateSubnetIds" ))
139- imported_vpc = ec2 .Vpc .from_vpc_attributes (self , f"ImportedVPC-{ color } " , vpc_id = vpc_id , availability_zones = availability_zones , private_subnet_ids = private_subnet_ids )
135+
140136 cluster = ecs .Cluster .from_cluster_attributes (self , f"Cluster-{ color } " ,
141137 cluster_name = core .Fn .import_value (f"{ environment_name } :ECSCluster" ),
142138 vpc = imported_vpc ,
@@ -249,7 +245,7 @@ def __init__(self, scope: Construct, id: str, **kwargs, ) -> None:
249245 # Loop through all the colors to create their task definitions and ECS services
250246 for color in color_teller_colors :
251247 task_definition = self .create_color_task_definition (color , environment_name )
252- service = self .create_color_service (color , namespace , taskdef = task_definition )
248+ service = self .create_color_service (color , namespace , taskdef = task_definition , imported_vpc = imported_vpc )
253249
254250 core .CfnOutput (
255251 self , f"ColorTellerTaskDefinitionArn-{ color } " ,
0 commit comments