11import * as cdk from "aws-cdk-lib" ;
2+ import { Construct } from "constructs" ;
23import { Database } from "./database-stack" ;
34import { Guardrail } from "./guardrail-stack" ;
45import { PromptSwitch } from "./prompt-switch-stack" ;
56import { Api } from "./api-stack" ;
7+ import { Waf } from './waf-stack' ;
68import { FrontEnd } from "./front-end-stack" ;
79import { Observability } from "./observability-stack" ;
810
9- export interface MainStackProps extends cdk . StackProps { }
11+ export interface MainStackProps extends cdk . StackProps {
12+ env ?: {
13+ region ?: string ;
14+ account ?: string ;
15+ } ;
16+ }
1017
1118export class MainStack extends cdk . Stack {
1219 public readonly approvedMessagesTableName : string ;
@@ -25,9 +32,11 @@ export class MainStack extends cdk.Stack {
2532 public readonly cloudFrontDistributionId : string ;
2633 public readonly cloudFrontDistributionDomain : string ;
2734
28- public constructor ( scope : cdk . App , id : string , props : MainStackProps = { } ) {
29- super ( scope , id , props ) ;
30- this . templateOptions . description = 'Live Chat Content Moderation with generative AI on AWS (SO9005)'
35+ constructor ( scope : Construct , id : string , props ?: MainStackProps ) {
36+ super ( scope , id , {
37+ ...props ,
38+ crossRegionReferences : true ,
39+ } ) ;
3140
3241 // Database Nested Stack
3342 const database = new Database ( this , "Database" , {
@@ -56,9 +65,20 @@ export class MainStack extends cdk.Stack {
5665 promptSwitchParameterName : promptSwitch . promptSwitchParameterName ,
5766 } ) ;
5867
68+ // WAF Nested Stack in us-east-1
69+ const wafStack = new Waf ( this , 'Waf' , {
70+ stackName : "Waf" ,
71+ crossRegionReferences : true ,
72+ env : {
73+ account : this . account ,
74+ } ,
75+ } ) ;
76+
5977 // Front-End Nested Stack
6078 const frontEnd = new FrontEnd ( this , "FrontEnd" , {
6179 stackName : "FrontEnd" ,
80+ webAclArn : wafStack . webAclArn ,
81+ crossRegionReferences : true ,
6282 } ) ;
6383
6484 // Observability Stack
0 commit comments