Skip to content

Commit 4cf9dd7

Browse files
authored
Fix: [AEA-5895] - send waf logs to csoc (#1430)
## Summary - Routine Change ### Details - send waf logs to csoc
1 parent b1d8ab5 commit 4cf9dd7

File tree

11 files changed

+55
-2
lines changed

11 files changed

+55
-2
lines changed

.github/scripts/fix_cdk_json.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ 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 csocUKWafDestination "arn:aws:logs:eu-west-2:693466633220:destination:waf_log_destination" # CSOC WAF log destination - do not change
185+
fix_string_key csocUSWafDestination "arn:aws:logs:us-east-1:693466633220:destination:waf_log_destination_virginia" # CSOC WAF log destination - do not change
186+
fix_boolean_number_key forwardCsocLogs "${FORWARD_CSOC_LOGS}"
184187

185188
if [ "$CDK_APP_NAME" == "StatefulResourcesApp" ]; then
186189
fix_string_key primaryOidcClientId "${PRIMARY_OIDC_CLIENT_ID}"

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
MARK_JIRA_RELEASED: false
9999
CREATE_INT_RC_RELEASE_NOTES: false
100100
IS_PULL_REQUEST: false
101+
FORWARD_CSOC_LOGS: false
101102
secrets: inherit
102103

103104
release_qa:
@@ -135,4 +136,5 @@ jobs:
135136
REACT_LOG_LEVEL: "debug"
136137
LOG_RETENTION_IN_DAYS: 30
137138
IS_PULL_REQUEST: false
139+
FORWARD_CSOC_LOGS: false
138140
secrets: inherit

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ jobs:
212212
REACT_LOG_LEVEL: "debug"
213213
LOG_RETENTION_IN_DAYS: 30
214214
IS_PULL_REQUEST: true
215+
FORWARD_CSOC_LOGS: false
215216
secrets: inherit
216217
report_deployed_url:
217218
needs: [release_code, get_issue_number]

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
MARK_JIRA_RELEASED: false
9898
CREATE_INT_RC_RELEASE_NOTES: false
9999
IS_PULL_REQUEST: false
100+
FORWARD_CSOC_LOGS: false
100101
secrets: inherit
101102

102103
release_ref:
@@ -134,6 +135,7 @@ jobs:
134135
REACT_LOG_LEVEL: "debug"
135136
LOG_RETENTION_IN_DAYS: 30
136137
IS_PULL_REQUEST: false
138+
FORWARD_CSOC_LOGS: false
137139
secrets: inherit
138140

139141
release_qa:
@@ -171,6 +173,7 @@ jobs:
171173
REACT_LOG_LEVEL: "debug"
172174
LOG_RETENTION_IN_DAYS: 30
173175
IS_PULL_REQUEST: false
176+
FORWARD_CSOC_LOGS: false
174177
secrets: inherit
175178
release_int:
176179
needs: [tag_release, package_code, get_commit_id, release_qa]
@@ -207,6 +210,7 @@ jobs:
207210
MARK_JIRA_RELEASED: false
208211
CREATE_INT_RC_RELEASE_NOTES: true
209212
IS_PULL_REQUEST: false
213+
FORWARD_CSOC_LOGS: false
210214
secrets: inherit
211215
release_prod:
212216
needs: [tag_release, package_code, get_commit_id, release_int]
@@ -243,4 +247,5 @@ jobs:
243247
MARK_JIRA_RELEASED: false
244248
CREATE_INT_RC_RELEASE_NOTES: false
245249
IS_PULL_REQUEST: false
250+
FORWARD_CSOC_LOGS: true
246251
secrets: inherit

.github/workflows/release_all_stacks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ on:
9090
IS_PULL_REQUEST:
9191
type: boolean
9292
required: true
93+
FORWARD_CSOC_LOGS:
94+
type: boolean
95+
required: true
9396
jobs:
9497
release_all_code:
9598
runs-on: ubuntu-22.04
@@ -245,6 +248,7 @@ jobs:
245248
WAF_ALLOW_GA_RUNNER_CONNECTIVITY: ${{ inputs.WAF_ALLOW_GA_RUNNER_CONNECTIVITY }}
246249
CLOUDFRONT_ORIGIN_CUSTOM_HEADER: ${{secrets.CLOUDFRONT_ORIGIN_CUSTOM_HEADER }}
247250
IS_PULL_REQUEST: ${{inputs.IS_PULL_REQUEST}}
251+
FORWARD_CSOC_LOGS: ${{ inputs.FORWARD_CSOC_LOGS }}
248252

249253
- name: Show diff for stateful stack
250254
run: |
@@ -383,6 +387,7 @@ jobs:
383387
WAF_ALLOW_GA_RUNNER_CONNECTIVITY: ${{ inputs.WAF_ALLOW_GA_RUNNER_CONNECTIVITY }}
384388
CLOUDFRONT_ORIGIN_CUSTOM_HEADER: ${{secrets.CLOUDFRONT_ORIGIN_CUSTOM_HEADER }}
385389
IS_PULL_REQUEST: ${{inputs.IS_PULL_REQUEST}}
390+
FORWARD_CSOC_LOGS: ${{ inputs.FORWARD_CSOC_LOGS }}
386391

387392
- name: Show diff for stateless stack
388393
run: |
@@ -510,6 +515,7 @@ jobs:
510515
WAF_ALLOW_GA_RUNNER_CONNECTIVITY: ${{ inputs.WAF_ALLOW_GA_RUNNER_CONNECTIVITY }}
511516
CLOUDFRONT_ORIGIN_CUSTOM_HEADER: ${{secrets.CLOUDFRONT_ORIGIN_CUSTOM_HEADER }}
512517
IS_PULL_REQUEST: ${{inputs.IS_PULL_REQUEST}}
518+
FORWARD_CSOC_LOGS: ${{ inputs.FORWARD_CSOC_LOGS }}
513519

514520
- name: Show diff for stateful stack redeployment
515521
if: ${{ steps.check_redeploy_stateful_stack.outputs.REDEPLOY_STATEFUL_STACK == 'true' }}

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ cdk-synth-stateful-resources-no-mock:
218218
DO_NOT_GET_AWS_EXPORT=true \
219219
IS_PULL_REQUEST=false \
220220
USE_ZONE_APEX=false \
221+
FORWARD_CSOC_LOGS=true \
221222
./.github/scripts/fix_cdk_json.sh .local_config/stateful_app.config.json
222223
CONFIG_FILE_NAME=.local_config/stateful_app.config.json npx cdk synth \
223224
--quiet \
@@ -267,6 +268,7 @@ cdk-synth-stateless-resources-no-mock:
267268
CLOUDFRONT_ORIGIN_CUSTOM_HEADER=foo \
268269
IS_PULL_REQUEST=false \
269270
USE_ZONE_APEX=false \
271+
FORWARD_CSOC_LOGS=true \
270272
./.github/scripts/fix_cdk_json.sh .local_config/stateless_app.config.json
271273
CONFIG_FILE_NAME=.local_config/stateless_app.config.json npx cdk synth \
272274
--quiet \
@@ -313,6 +315,7 @@ cdk-synth-stateful-resources-mock:
313315
DO_NOT_GET_AWS_EXPORT=true \
314316
IS_PULL_REQUEST=false \
315317
USE_ZONE_APEX=false \
318+
FORWARD_CSOC_LOGS=true \
316319
./.github/scripts/fix_cdk_json.sh .local_config/stateful_app.config.json
317320
CONFIG_FILE_NAME=.local_config/stateful_app.config.json npx cdk synth \
318321
--quiet \
@@ -368,6 +371,7 @@ cdk-synth-stateless-resources-mock:
368371
CLOUDFRONT_ORIGIN_CUSTOM_HEADER=foo \
369372
IS_PULL_REQUEST=false \
370373
USE_ZONE_APEX=false \
374+
FORWARD_CSOC_LOGS=true \
371375
./.github/scripts/fix_cdk_json.sh .local_config/stateless_app.config.json
372376
CONFIG_FILE_NAME=.local_config/stateless_app.config.json npx cdk synth \
373377
--quiet \

packages/cdk/resources/ukRegionLogGroups.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export interface ukRegionLogGroupsProps {
1212
readonly splunkSubscriptionFilterRole: IRole
1313
readonly wafLogGroupName: string
1414
readonly stackName: string
15+
readonly csocUKWafDestination: string
16+
readonly forwardCsocLogs: boolean
1517
}
1618

1719
export class ukRegionLogGroups extends Construct {
@@ -43,6 +45,15 @@ export class ukRegionLogGroups extends Construct {
4345
roleArn: props.splunkSubscriptionFilterRole.roleArn
4446
})
4547

48+
if (props.forwardCsocLogs) {
49+
new CfnSubscriptionFilter(this, "CsocWafSplunkSubscriptionFilter", {
50+
destinationArn: props.csocUKWafDestination,
51+
filterPattern: "",
52+
logGroupName: wafLogGroup.logGroupName,
53+
roleArn: props.splunkSubscriptionFilterRole.roleArn
54+
})
55+
}
56+
4657
this.wafLogGroup = wafLogGroup
4758
}
4859

packages/cdk/resources/usRegionLogGroups.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export interface usRegionLogGroupsProps {
2626
readonly splunkDeliveryStream: string
2727
readonly splunkSubscriptionFilterRole: string
2828
readonly isPullRequest: boolean
29+
readonly csocUSWafDestination: string
30+
readonly forwardCsocLogs: boolean
2931
}
3032

3133
export class usRegionLogGroups extends Construct {
@@ -126,6 +128,15 @@ export class usRegionLogGroups extends Construct {
126128
removalPolicy: RemovalPolicy.DESTROY
127129
})
128130

131+
if (props.forwardCsocLogs) {
132+
new CfnSubscriptionFilter(this, "CsocWafSplunkSubscriptionFilter", {
133+
destinationArn: props.csocUSWafDestination,
134+
filterPattern: "",
135+
logGroupName: wafLogGroup.logGroupName,
136+
roleArn: props.splunkSubscriptionFilterRole
137+
})
138+
}
139+
129140
const cfnWafLogGroup = wafLogGroup.node.defaultChild as CfnLogGroup
130141
cfnWafLogGroup.cfnOptions.metadata = {
131142
guard: {

packages/cdk/stacks/StatelessResourcesStack.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ 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 csocUKWafDestination: string = this.node.tryGetContext("csocUKWafDestination")
101+
const forwardCsocLogs: boolean = this.node.tryGetContext("forwardCsocLogs")
100102

101103
// Imports
102104
const baseImportPath = `${props.serviceName}-stateful-resources`
@@ -316,7 +318,9 @@ export class StatelessResourcesStack extends Stack {
316318
splunkSubscriptionFilterRole: splunkSubscriptionFilterRole,
317319
// waf log groups must start with aws-waf-logs-
318320
wafLogGroupName: `aws-waf-logs-${props.serviceName}-apigw`,
319-
stackName: this.stackName
321+
stackName: this.stackName,
322+
csocUKWafDestination: csocUKWafDestination,
323+
forwardCsocLogs: forwardCsocLogs
320324
})
321325

322326
// API Gateway WAF Web ACL

packages/cdk/stacks/UsCertsStack.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ 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 csocUSWafDestination: string = this.node.tryGetContext("csocUSWafDestination")
55+
const forwardCsocLogs: boolean = this.node.tryGetContext("forwardCsocLogs")
5456

5557
// Coerce context and imports to relevant types
5658
const hostedZone = HostedZone.fromHostedZoneAttributes(this, "hostedZone", {
@@ -107,7 +109,9 @@ export class UsCertsStack extends Stack {
107109
account: this.account,
108110
splunkDeliveryStream: splunkDeliveryStream,
109111
splunkSubscriptionFilterRole: splunkSubscriptionFilterRole,
110-
isPullRequest: isPullRequest
112+
isPullRequest: isPullRequest,
113+
csocUSWafDestination: csocUSWafDestination,
114+
forwardCsocLogs: forwardCsocLogs
111115
})
112116

113117
// WAF Web ACL

0 commit comments

Comments
 (0)