Skip to content

Commit

Permalink
fix(waf): updating cdn waf
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Aug 28, 2024
1 parent 7d927c3 commit 0815708
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 28 deletions.
2 changes: 1 addition & 1 deletion infrastructure/braze-content-proxy/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BrazeContentProxy extends TerraformStack {
return new wafv2WebAcl.Wafv2WebAcl(this, `${config.name}-waf`, {
description: `Waf for ${config.name} ${config.environment} environment`,
name: `${config.name}-waf-${config.environment}`,
scope: 'REGIONAL',
scope: 'CLOUDFRONT',
defaultAction: { allow: {} },
visibilityConfig: {
cloudwatchMetricsEnabled: true,
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/client-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class ClientAPI extends TerraformStack {
return new Wafv2WebAcl(this, `${config.name}-waf`, {
description: `Waf for client-api-proxy ${config.environment} environment`,
name: `${config.name}-waf-${config.environment}`,
scope: 'REGIONAL',
scope: 'CLOUDFRONT',
defaultAction: { allow: {} },
visibilityConfig: {
cloudwatchMetricsEnabled: true,
Expand Down
21 changes: 2 additions & 19 deletions packages/terraform-modules/src/pocket/PocketALBApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,7 @@ export class PocketALBApplication extends Construct {
this.alb = alb;

if (config.cdn) {
const cdn = this.createCDN(albRecord);
// If we have a CDN, add the WAF to the CDN
if (config.wafConfig) {
this.createWAFCDN(cdn, config.wafConfig.aclArn);
}
this.createCDN(albRecord);
}

// If we don't have a CDN add the WAF to the ALB
Expand Down Expand Up @@ -407,20 +403,6 @@ export class PocketALBApplication extends Construct {
);
}

private createWAFCDN(
cdn: cloudfrontDistribution.CloudfrontDistribution,
webAclArn: string,
) {
new wafv2WebAclAssociation.Wafv2WebAclAssociation(
this,
'application_waf_association',
{
webAclArn: webAclArn,
resourceArn: cdn.arn,
},
);
}

/**
* Creates the ALB stack and certificates
* @private
Expand Down Expand Up @@ -510,6 +492,7 @@ export class PocketALBApplication extends Construct {
aliases: [this.config.domain],
priceClass: 'PriceClass_200',
tags: this.config.tags,
webAclId: this.config.wafConfig?.aclArn ?? undefined,
origin: [
{
domainName: albRecord.fqdn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9413,7 +9413,8 @@ exports[`PocketALBApplication renders an external application with a CDN and a w
"acm_certificate_arn": "\${aws_acm_certificate.testPocketApp_cdn_certificate_F1CBB9BB.arn}",
"minimum_protocol_version": "TLSv1.1_2016",
"ssl_support_method": "sni-only"
}
},
"web_acl_id": "some-arn"
}
},
"aws_cloudwatch_dashboard": {
Expand Down Expand Up @@ -9723,12 +9724,6 @@ exports[`PocketALBApplication renders an external application with a CDN and a w
"name_prefix": "testapp-ECSSecurityGroup",
"vpc_id": "\${data.aws_vpc.testPocketApp_pocket_vpc_C4E157E3.id}"
}
},
"aws_wafv2_web_acl_association": {
"testPocketApp_application_waf_association_03F7C3FB": {
"resource_arn": "\${aws_cloudfront_distribution.testPocketApp_cloudfront_distribution_FD7F01BF.arn}",
"web_acl_arn": "some-arn"
}
}
}
}"
Expand Down

0 comments on commit 0815708

Please sign in to comment.