Skip to content

Commit 0a47d7e

Browse files
committed
send waf to csoc
1 parent 85aa178 commit 0a47d7e

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

.github/scripts/fix_cdk_json.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ fix_string_key logRetentionInDays "${LOG_RETENTION_IN_DAYS}"
181181
fix_string_key logLevel "${LOG_LEVEL}"
182182
fix_string_key cfnDriftDetectionGroup "${CFN_DRIFT_DETECTION_GROUP}"
183183
fix_boolean_number_key isPullRequest "${IS_PULL_REQUEST}"
184+
fix_string_key csocWafDestination "arn:aws:logs:eu-west-2:693466633220:destination:waf_log_destination" # CSOC WAF log destination - do not change
184185

185186
if [ "$CDK_APP_NAME" == "StatefulResourcesApp" ]; then
186187
fix_string_key primaryOidcClientId "${PRIMARY_OIDC_CLIENT_ID}"

packages/cdk/resources/ukRegionLogGroups.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface ukRegionLogGroupsProps {
1212
readonly splunkSubscriptionFilterRole: IRole
1313
readonly wafLogGroupName: string
1414
readonly stackName: string
15+
readonly csocWafDestination: string
1516
}
1617

1718
export class ukRegionLogGroups extends Construct {
@@ -43,6 +44,13 @@ export class ukRegionLogGroups extends Construct {
4344
roleArn: props.splunkSubscriptionFilterRole.roleArn
4445
})
4546

47+
new CfnSubscriptionFilter(this, "CsocWafSplunkSubscriptionFilter", {
48+
destinationArn: props.csocWafDestination,
49+
filterPattern: "",
50+
logGroupName: wafLogGroup.logGroupName,
51+
roleArn: props.splunkSubscriptionFilterRole.roleArn
52+
})
53+
4654
this.wafLogGroup = wafLogGroup
4755
}
4856

packages/cdk/resources/usRegionLogGroups.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface usRegionLogGroupsProps {
2626
readonly splunkDeliveryStream: string
2727
readonly splunkSubscriptionFilterRole: string
2828
readonly isPullRequest: boolean
29+
readonly csocWafDestination: string
2930
}
3031

3132
export class usRegionLogGroups extends Construct {
@@ -126,6 +127,13 @@ export class usRegionLogGroups extends Construct {
126127
removalPolicy: RemovalPolicy.DESTROY
127128
})
128129

130+
new CfnSubscriptionFilter(this, "CsocWafSplunkSubscriptionFilter", {
131+
destinationArn: props.csocWafDestination,
132+
filterPattern: "",
133+
logGroupName: wafLogGroup.logGroupName,
134+
roleArn: props.splunkSubscriptionFilterRole
135+
})
136+
129137
const cfnWafLogGroup = wafLogGroup.node.defaultChild as CfnLogGroup
130138
cfnWafLogGroup.cfnOptions.metadata = {
131139
guard: {

packages/cdk/stacks/StatelessResourcesStack.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export class StatelessResourcesStack extends Stack {
9797
const githubAllowListIpv4 = this.node.tryGetContext("githubAllowListIpv4")
9898
const githubAllowListIpv6 = this.node.tryGetContext("githubAllowListIpv6")
9999
const cloudfrontOriginCustomHeader = this.node.tryGetContext("cloudfrontOriginCustomHeader")
100+
const csocWafDestination: string = this.node.tryGetContext("csocWafDestination")
100101

101102
// Imports
102103
const baseImportPath = `${props.serviceName}-stateful-resources`
@@ -316,7 +317,8 @@ export class StatelessResourcesStack extends Stack {
316317
splunkSubscriptionFilterRole: splunkSubscriptionFilterRole,
317318
// waf log groups must start with aws-waf-logs-
318319
wafLogGroupName: `aws-waf-logs-${props.serviceName}-apigw`,
319-
stackName: this.stackName
320+
stackName: this.stackName,
321+
csocWafDestination: csocWafDestination
320322
})
321323

322324
// API Gateway WAF Web ACL

packages/cdk/stacks/UsCertsStack.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class UsCertsStack extends Stack {
5151
const cloudfrontDistributionArn: string = this.node.tryGetContext("cloudfrontDistributionArn")
5252
const logRetentionInDays: number = Number(this.node.tryGetContext("logRetentionInDays"))
5353
const isPullRequest: boolean = this.node.tryGetContext("isPullRequest")
54+
const csocWafDestination: string = this.node.tryGetContext("csocWafDestination")
5455

5556
// Coerce context and imports to relevant types
5657
const hostedZone = HostedZone.fromHostedZoneAttributes(this, "hostedZone", {
@@ -107,7 +108,8 @@ export class UsCertsStack extends Stack {
107108
account: this.account,
108109
splunkDeliveryStream: splunkDeliveryStream,
109110
splunkSubscriptionFilterRole: splunkSubscriptionFilterRole,
110-
isPullRequest: isPullRequest
111+
isPullRequest: isPullRequest,
112+
csocWafDestination: csocWafDestination
111113
})
112114

113115
// WAF Web ACL

0 commit comments

Comments
 (0)