@@ -155,18 +155,16 @@ def handle(self) -> int:
155155 # Deploy all configured stacks in dependency order
156156 stacks_to_deploy .append (("auth" , "Authentication Stack (Cognito + IAM)" ))
157157
158- # Deploy networking first if needed (required by landing-page distribution and monitoring)
159- if profile .monitoring_enabled or (
160- profile .enable_distribution and profile .distribution_type == "landing-page"
161- ):
162- stacks_to_deploy .append (("networking" , "VPC Networking for OTEL Collector" ))
163-
164158 # Deploy distribution after networking if it's landing-page type
165159 if profile .enable_distribution :
166160 stacks_to_deploy .append (("distribution" , "Distribution infrastructure (S3 + IAM)" ))
167161
168162 # Deploy remaining monitoring stacks
169163 if profile .monitoring_enabled :
164+ vpc_congig = profile .monitoring_config or {}
165+ if vpc_congig .get ("create_vpc" , True ):
166+ stacks_to_deploy .append (("networking" , "VPC Networking for OTEL Collector" ))
167+ stacks_to_deploy .append (("s3bucket" , "S3 Bucket" ))
170168 stacks_to_deploy .append (("monitoring" , "OpenTelemetry Collector" ))
171169 stacks_to_deploy .append (("dashboard" , "CloudWatch Dashboard" ))
172170 # Check if analytics is enabled (default to True for backward compatibility)
@@ -563,6 +561,7 @@ def deploy_with_cf(
563561 template = project_root / "deployment" / "infrastructure" / "networking.yaml"
564562 stack_name = profile .stack_names .get ("networking" , f"{ profile .identity_pool_name } -networking" )
565563 vpc_config = profile .monitoring_config or {}
564+
566565 params = [
567566 f"VpcCidr={ vpc_config .get ('vpc_cidr' , '10.0.0.0/16' )} " ,
568567 f"PublicSubnet1Cidr={ vpc_config .get ('subnet1_cidr' , '10.0.1.0/24' )} " ,
@@ -572,34 +571,46 @@ def deploy_with_cf(
572571 template , stack_name , params , task_description = "Deploying networking infrastructure..."
573572 )
574573
574+ elif stack_type == "s3bucket" :
575+ template = project_root / "deployment" / "infrastructure" / "s3bucket.yaml"
576+ stack_name = profile .stack_names .get ("networking" , f"{ profile .identity_pool_name } -s3bucket" )
577+ params = []
578+ return deploy_with_cf (template , stack_name , params , task_description = "Deploying S3 Bucket..." )
575579 elif stack_type == "monitoring" :
576580 # Ensure ECS service linked role exists before deploying
577581 self ._ensure_ecs_service_linked_role (console )
578582
579583 template = project_root / "deployment" / "infrastructure" / "otel-collector.yaml"
580584 stack_name = profile .stack_names .get ("monitoring" , f"{ profile .identity_pool_name } -otel-collector" )
585+ params = []
586+ vpc_congig = profile .monitoring_config or {}
581587
582- # Get VPC outputs from networking stack
583- networking_stack_name = profile .stack_names .get (
584- "networking" , f"{ profile .identity_pool_name } -networking"
585- )
586- networking_outputs = get_stack_outputs (networking_stack_name , profile .aws_region )
588+ if not vpc_congig .get ("create_vpc" , True ):
589+ params .append (f"VpcId={ vpc_congig .get ('vpc_id' , '' )} " )
590+ subnet_ids = "," .join (vpc_congig .get ("subnet_ids" , []))
591+ params .append (f"SubnetIds={ subnet_ids } " )
592+ else :
593+ # Get VPC outputs from networking stack
594+ networking_stack_name = profile .stack_names .get (
595+ "networking" , f"{ profile .identity_pool_name } -networking"
596+ )
597+ networking_outputs = get_stack_outputs (networking_stack_name , profile .aws_region )
587598
588- params = []
589- if networking_outputs :
590- vpc_id = networking_outputs .get ("VpcId" , "" )
591- subnet_ids = networking_outputs .get ("SubnetIds" , "" )
592- if vpc_id :
593- params .append (f"VpcId={ vpc_id } " )
594- if subnet_ids :
595- params .append (f"SubnetIds={ subnet_ids } " )
599+ if networking_outputs :
600+ vpc_id = networking_outputs .get ("VpcId" , "" )
601+ subnet_ids = networking_outputs .get ("SubnetIds" , "" )
602+ if vpc_id :
603+ params .append (f"VpcId={ vpc_id } " )
604+ if subnet_ids :
605+ params .append (f"SubnetIds={ subnet_ids } " )
596606
597607 # Add HTTPS domain parameters if configured
598608 monitoring_config = getattr (profile , "monitoring_config" , {})
599609 if monitoring_config .get ("custom_domain" ):
600610 params .append (f"CustomDomainName={ monitoring_config ['custom_domain' ]} " )
601611 params .append (f"HostedZoneId={ monitoring_config ['hosted_zone_id' ]} " )
602612
613+ console .print (f"[dim]Using parameters: { params } [/dim]" )
603614 return deploy_with_cf (
604615 template , stack_name , params , task_description = "Deploying monitoring collector..."
605616 )
@@ -609,20 +620,18 @@ def deploy_with_cf(
609620 stack_name = profile .stack_names .get ("dashboard" , f"{ profile .identity_pool_name } -dashboard" )
610621
611622 # Get S3 bucket from networking stack for packaging
612- networking_stack_name = profile .stack_names .get (
613- "networking" , f"{ profile .identity_pool_name } -networking"
614- )
615- networking_outputs = get_stack_outputs (networking_stack_name , profile .aws_region )
623+ s3_stack_name = profile .stack_names .get ("s3" , f"{ profile .identity_pool_name } -s3bucket" )
624+ s3_outputs = get_stack_outputs (s3_stack_name , profile .aws_region )
616625
617- if not networking_outputs or not networking_outputs .get ("CfnArtifactsBucket" ):
626+ if not s3_outputs or not s3_outputs .get ("CfnArtifactsBucket" ):
618627 console .print ("[red]Error: S3 bucket for packaging not found[/red]" )
619628 console .print (
620629 "[yellow]The networking stack must be deployed first with the artifacts bucket.[/yellow]"
621630 )
622631 console .print ("Run: [cyan]ccwb deploy networking[/cyan]" )
623632 return 1
624633
625- s3_bucket = networking_outputs ["CfnArtifactsBucket" ]
634+ s3_bucket = s3_outputs ["CfnArtifactsBucket" ]
626635
627636 # Package the template using AWS CLI (simple and reliable!)
628637 task = progress .add_task ("Packaging dashboard Lambda functions..." , total = None )
0 commit comments