@@ -16,6 +16,7 @@ import { WebAcl } from '../aws-waf';
1616
1717interface SupabaseCdnProps {
1818 origin : string | elb . ILoadBalancerV2 ;
19+ webAclArn : cdk . CfnParameter ;
1920}
2021
2122interface BehaviorProps {
@@ -26,9 +27,6 @@ interface BehaviorProps {
2627export class SupabaseCdn extends Construct {
2728 distribution : cf . Distribution ;
2829 defaultBehaviorOptions : cf . AddBehaviorOptions ;
29- cfnParameters : {
30- webAclArn : cdk . CfnParameter ;
31- } ;
3230
3331 /** Construct for CloudFront and WAF */
3432 constructor ( scope : Construct , id : string , props : SupabaseCdnProps ) {
@@ -39,23 +37,14 @@ export class SupabaseCdn extends Construct {
3937 ? new HttpOrigin ( props . origin , { protocolPolicy : cf . OriginProtocolPolicy . HTTPS_ONLY } )
4038 : new LoadBalancerV2Origin ( props . origin , { protocolPolicy : cf . OriginProtocolPolicy . HTTP_ONLY } ) ;
4139
42- this . cfnParameters = {
43- webAclArn : new cdk . CfnParameter ( this , 'WebAclArn' , {
44- description : 'Web ACL for CloudFront.' ,
45- type : 'String' ,
46- default : '' ,
47- allowedPattern : '^arn:aws:wafv2:us-east-1:[0-9]{12}:global/webacl/[\\w-]+/[\\w]{8}-[\\w]{4}-[\\w]{4}-[\\w]{4}-[\\w]{12}$|' ,
48- } ) ,
49- } ;
50-
51- const webAclUndefined = new cdk . CfnCondition ( this , 'WebAclUndefined' , { expression : cdk . Fn . conditionEquals ( this . cfnParameters . webAclArn , '' ) } ) ;
40+ const defaultWebAclEnabled = new cdk . CfnCondition ( this , 'DefaultWebAclEnabled' , { expression : cdk . Fn . conditionEquals ( props . webAclArn , '' ) } ) ;
5241
5342 /** Default Web ACL */
54- const webAcl = new WebAcl ( this , 'WebAcl ' , { description : 'Supabase Standard WebAcl ' } ) ;
55- ( webAcl . node . defaultChild as cdk . CfnStack ) . cfnOptions . condition = webAclUndefined ;
43+ const defaultWebAcl = new WebAcl ( this , 'DefaultWebAcl ' , { description : 'Default Web ACL ' } ) ;
44+ ( defaultWebAcl . node . defaultChild as cdk . CfnStack ) . cfnOptions . condition = defaultWebAclEnabled ;
5645
5746 /** Web ACL ID */
58- const webAclId = cdk . Fn . conditionIf ( webAclUndefined . logicalId , webAcl . webAclArn , this . cfnParameters . webAclArn . valueAsString ) ;
47+ const webAclId = cdk . Fn . conditionIf ( defaultWebAclEnabled . logicalId , defaultWebAcl . webAclArn , props . webAclArn . valueAsString ) ;
5948
6049 const cachePolicy = new cf . CachePolicy ( this , 'CachePolicy' , {
6150 cachePolicyName : `${ cdk . Aws . STACK_NAME } -CachePolicy-${ cdk . Aws . REGION } ` ,
0 commit comments