11package sample .com ;
22
3+ import software .amazon .awscdk .RemovalPolicy ;
34import software .amazon .awscdk .Stack ;
45import software .amazon .awscdk .StackProps ;
6+ import software .amazon .awscdk .services .ecr .Repository ;
57import software .constructs .Construct ;
68import sample .com .constructs .*;
79import sample .com .constructs .Ide .IdeProps ;
@@ -47,6 +49,12 @@ public WorkshopStack(final Construct scope, final String id, final StackProps pr
4749 gitBranch = "main" ; // fallback
4850 }
4951
52+ // Template type flags
53+ boolean isImmersionDay = "java-on-aws-immersion-day" .equals (templateType );
54+ boolean isEks = "java-on-amazon-eks" .equals (templateType );
55+ boolean isSpringAi = "java-spring-ai-agents" .equals (templateType );
56+ boolean isFullTemplate = isImmersionDay || isEks || isSpringAi ;
57+
5058 // Core infrastructure (always created)
5159 Vpc vpc = new Vpc (this , "Vpc" , Vpc .VpcProps .builder ()
5260 .prefix (prefix )
@@ -61,8 +69,8 @@ public WorkshopStack(final Construct scope, final String id, final StackProps pr
6169 .build ();
6270 Ide ide = new Ide (this , "Ide" , ideProps );
6371
64- // java-on-aws-immersion-day, java-on-amazon-eks, and java-spring-ai-agents specific resources (CodeBuild for service-linked roles )
65- if ("java-on-aws-immersion-day" . equals ( templateType ) || "java-on-amazon-eks" . equals ( templateType ) || "java-spring-ai-agents" . equals ( templateType ) ) {
72+ // Full template resources ( java-on-aws-immersion-day, java-on-amazon-eks, java-spring-ai-agents)
73+ if (isFullTemplate ) {
6674 // CodeBuild for workshop setup (service-linked role creation)
6775 new CodeBuild (this , "CodeBuild" ,
6876 CodeBuild .CodeBuildProps .builder ()
@@ -75,7 +83,7 @@ public WorkshopStack(final Construct scope, final String id, final StackProps pr
7583 .buildSpec (buildSpec )
7684 .build ());
7785
78- // Database, EKS, PerformanceAnalysis, Unicorn
86+ // Database
7987 Database database = new Database (this , "Database" , Database .DatabaseProps .builder ()
8088 .prefix (prefix )
8189 .vpc (vpc .getVpc ())
@@ -89,7 +97,7 @@ public WorkshopStack(final Construct scope, final String id, final StackProps pr
8997 .ideInternalSecurityGroup (ide .getIdeInternalSecurityGroup ())
9098 .build ());
9199
92- // Shared workshop bucket for thread dumps and profiling data
100+ // Shared workshop bucket
93101 WorkshopBucket workshopBucket = new WorkshopBucket (this , "WorkshopBucket" ,
94102 WorkshopBucket .WorkshopBucketProps .builder ()
95103 .prefix (prefix )
@@ -101,29 +109,61 @@ public WorkshopStack(final Construct scope, final String id, final StackProps pr
101109 .prefix (prefix )
102110 .build ());
103111
104- // Thread Analysis (thread dump Lambda + API Gateway)
105- new ThreadAnalysis (this , "ThreadAnalysis" ,
106- ThreadAnalysis .ThreadAnalysisProps .builder ()
107- .prefix (prefix )
108- .vpc (vpc .getVpc ())
109- .eksCluster (eks .getCluster ())
110- .eksClusterName (eks .getClusterName ())
111- .workshopBucket (workshopBucket .getBucket ())
112- .build ());
113-
114- // AI JVM Analyzer (Pod Identity role for ai-jvm-analyzer)
115- new AiJvmAnalyzer (this , "AiJvmAnalyzer" ,
116- AiJvmAnalyzer .AiJvmAnalyzerProps .builder ()
117- .workshopBucket (workshopBucket .getBucket ())
118- .build ());
119-
120- // Unicorn construct: Roles + DB Setup (uses unicorn* naming for workshop content compatibility)
121- new Unicorn (this , "Unicorn" , Unicorn .UnicornProps .builder ()
112+ // Unicorn construct: EventBus, Roles, DB Setup (uses unicorn* naming for workshop content compatibility)
113+ Unicorn unicorn = new Unicorn (this , "Unicorn" , Unicorn .UnicornProps .builder ()
122114 .vpc (vpc .getVpc ())
123115 .database (database )
124116 .workshopBucket (workshopBucket .getBucket ())
125117 .build ());
126118
119+ // java-on-aws-immersion-day & java-on-amazon-eks specific resources
120+ if (isImmersionDay || isEks ) {
121+ // ECR repository for unicorn-store-spring (manual ECS Express deployment)
122+ Repository .Builder .create (this , "UnicornStoreSpringEcr" )
123+ .repositoryName ("unicorn-store-spring" )
124+ .imageScanOnPush (true )
125+ .removalPolicy (RemovalPolicy .DESTROY )
126+ .emptyOnDelete (true )
127+ .build ();
128+
129+ // Thread Analysis (thread dump Lambda + API Gateway)
130+ new ThreadAnalysis (this , "ThreadAnalysis" ,
131+ ThreadAnalysis .ThreadAnalysisProps .builder ()
132+ .prefix (prefix )
133+ .vpc (vpc .getVpc ())
134+ .eksCluster (eks .getCluster ())
135+ .eksClusterName (eks .getClusterName ())
136+ .workshopBucket (workshopBucket .getBucket ())
137+ .build ());
138+
139+ // AI JVM Analyzer (Pod Identity role for ai-jvm-analyzer)
140+ new AiJvmAnalyzer (this , "AiJvmAnalyzer" ,
141+ AiJvmAnalyzer .AiJvmAnalyzerProps .builder ()
142+ .workshopBucket (workshopBucket .getBucket ())
143+ .build ());
144+ }
145+
146+ // java-spring-ai-agents specific resources
147+ if (isSpringAi ) {
148+ // ECS Express Service for Spring AI Agent
149+ new EcsExpressService (this , "SpringAiAgent" ,
150+ EcsExpressService .EcsExpressServiceProps .builder ()
151+ .appName ("unicorn-spring-ai-agent" )
152+ .vpc (vpc .getVpc ())
153+ .database (database )
154+ .unicorn (unicorn )
155+ .build ());
156+
157+ // ECS Express Service for MCP Server
158+ new EcsExpressService (this , "McpServer" ,
159+ EcsExpressService .EcsExpressServiceProps .builder ()
160+ .appName ("unicorn-store-spring" )
161+ .vpc (vpc .getVpc ())
162+ .database (database )
163+ .unicorn (unicorn )
164+ .build ());
165+ }
166+
127167 // Pre-delete cleanup (removes VPC endpoints, CloudWatch logs, S3 contents before stack deletion)
128168 new CfnPreDeleteCleanup (this , "CfnPreDeleteCleanup" ,
129169 CfnPreDeleteCleanup .CfnPreDeleteCleanupProps .builder ()
0 commit comments