File tree Expand file tree Collapse file tree
packages/cdkConstructs/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,3 +17,8 @@ export const LAMBDA_RESOURCES = {
1717 SplunkDeliveryStream : Fn . importValue ( "lambda-resources:SplunkDeliveryStream" ) ,
1818 SplunkSubscriptionFilterRole : Fn . importValue ( "lambda-resources:SplunkSubscriptionFilterRole" )
1919}
20+
21+ /** Shared cfn-guard rule identifiers used for metadata suppressions. */
22+ export const CFN_GUARD_RULES = {
23+ LogGroupRetentionPeriodCheck : "CW_LOGGROUP_RETENTION_PERIOD_CHECK"
24+ } as const
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {
3333import { ApiGateway as ApiGatewayTarget } from "aws-cdk-lib/aws-route53-targets"
3434import { NagSuppressions } from "cdk-nag"
3535import { ACCOUNT_RESOURCES , LAMBDA_RESOURCES } from "../constants"
36+ import { addSuppressions } from "../utils/helpers"
3637
3738/** Configuration for creating a REST API with optional mTLS and log forwarding integrations. */
3839export interface RestApiGatewayProps {
@@ -257,13 +258,7 @@ export class RestApiGateway extends Construct {
257258 } )
258259
259260 const cfnStage = apiGateway . deploymentStage . node . defaultChild as CfnStage
260- cfnStage . cfnOptions . metadata = {
261- guard : {
262- SuppressedRules : [
263- "API_GW_CACHE_ENABLED_AND_ENCRYPTED"
264- ]
265- }
266- }
261+ addSuppressions ( [ cfnStage ] , [ "API_GW_CACHE_ENABLED_AND_ENCRYPTED" ] )
267262
268263 // Outputs
269264 this . api = apiGateway
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ import {
2020} from "aws-cdk-lib/aws-stepfunctions"
2121import { Construct } from "constructs"
2222import { CfnDeliveryStream } from "aws-cdk-lib/aws-kinesisfirehose"
23- import { ACCOUNT_RESOURCES , LAMBDA_RESOURCES } from "../constants"
23+ import { ACCOUNT_RESOURCES , CFN_GUARD_RULES , LAMBDA_RESOURCES } from "../constants"
24+ import { addSuppressions } from "../utils/helpers"
2425
2526/**
2627 * Configuration for provisioning an Express Step Functions state machine
@@ -109,13 +110,7 @@ export class ExpressStateMachine extends Construct {
109110 } )
110111
111112 const cfnLogGroup = logGroup . node . defaultChild as CfnLogGroup
112- cfnLogGroup . cfnOptions . metadata = {
113- guard : {
114- SuppressedRules : [
115- "CW_LOGGROUP_RETENTION_PERIOD_CHECK"
116- ]
117- }
118- }
113+ addSuppressions ( [ cfnLogGroup ] , [ CFN_GUARD_RULES . LogGroupRetentionPeriodCheck ] )
119114
120115 if ( addSplunkSubscriptionFilter ) {
121116 if ( splunkDeliveryStream ) {
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import {
1313} from "aws-cdk-lib/aws-iam"
1414import { NagSuppressions } from "cdk-nag"
1515import { LAMBDA_INSIGHTS_LAYER_ARNS } from "../config"
16- import { ACCOUNT_RESOURCES , LAMBDA_RESOURCES } from "../constants"
16+ import { ACCOUNT_RESOURCES , CFN_GUARD_RULES , LAMBDA_RESOURCES } from "../constants"
1717import { addSuppressions } from "../utils/helpers"
1818import { CfnDeliveryStream } from "aws-cdk-lib/aws-kinesisfirehose"
1919import { Stream } from "aws-cdk-lib/aws-kinesis"
@@ -74,7 +74,7 @@ export const createSharedLambdaResources = (
7474 } )
7575
7676 const cfnlogGroup = logGroup . node . defaultChild as CfnLogGroup
77- addSuppressions ( [ cfnlogGroup ] , [ "CW_LOGGROUP_RETENTION_PERIOD_CHECK" ] )
77+ addSuppressions ( [ cfnlogGroup ] , [ CFN_GUARD_RULES . LogGroupRetentionPeriodCheck ] )
7878
7979 if ( addSplunkSubscriptionFilter ) {
8080 // This is in an if statement to ensure correct value is used
You can’t perform that action at this time.
0 commit comments