Skip to content

Commit b8e25d8

Browse files
committed
Replace hardcoded account ID with variable in NAG suppressions
1 parent 77bab38 commit b8e25d8

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

packages/cdk/nagSuppressions.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {NagPackSuppression, NagSuppressions} from "cdk-nag"
44

55
export const nagSuppressions = (stack: Stack) => {
66
const stackName = stack.node.tryGetContext("stackName") || "epsam"
7+
const account = Stack.of(stack).account
78
// Suppress granular wildcard on log stream for SlackBot Lambda
89
safeAddNagSuppression(
910
stack,
@@ -98,10 +99,8 @@ export const nagSuppressions = (stack: Stack) => {
9899
"Action::bedrock:Delete*",
99100
"Resource::<StorageDocsBucketepsamDocsF25F63F1.Arn>/*",
100101
"Resource::<StorageDocsBucketepsampr16Docs240CC945.Arn>/*",
101-
"Resource::arn:aws:bedrock:eu-west-2:undefined:knowledge-base/*",
102-
"Resource::arn:aws:bedrock:eu-west-2:591291862413:knowledge-base/*",
103-
"Resource::arn:aws:aoss:eu-west-2:undefined:collection/*",
104-
"Resource::arn:aws:aoss:eu-west-2:591291862413:collection/*",
102+
`Resource::arn:aws:bedrock:eu-west-2:${account}:knowledge-base/*`,
103+
`Resource::arn:aws:aoss:eu-west-2:${account}:collection/*`,
105104
"Resource::*"
106105
]
107106
}
@@ -117,10 +116,8 @@ export const nagSuppressions = (stack: Stack) => {
117116
id: "AwsSolutions-IAM5",
118117
reason: "Lambda needs access to all OpenSearch collections and indexes to create and manage indexes.",
119118
appliesTo: [
120-
"Resource::arn:aws:aoss:eu-west-2:undefined:collection/*",
121-
"Resource::arn:aws:aoss:eu-west-2:undefined:index/*",
122-
"Resource::arn:aws:aoss:eu-west-2:591291862413:collection/*",
123-
"Resource::arn:aws:aoss:eu-west-2:591291862413:index/*"
119+
`Resource::arn:aws:aoss:eu-west-2:${account}:collection/*`,
120+
`Resource::arn:aws:aoss:eu-west-2:${account}:index/*`
124121
]
125122
}
126123
]
@@ -135,12 +132,9 @@ export const nagSuppressions = (stack: Stack) => {
135132
id: "AwsSolutions-IAM5",
136133
reason: "SlackBot Lambda needs access to all guardrails, knowledge bases, and functions for content filtering and self-invocation.",
137134
appliesTo: [
138-
"Resource::arn:aws:lambda:eu-west-2:undefined:function:*",
139-
"Resource::arn:aws:lambda:eu-west-2:591291862413:function:*",
140-
"Resource::arn:aws:bedrock:eu-west-2:undefined:guardrail/*",
141-
"Resource::arn:aws:bedrock:eu-west-2:591291862413:guardrail/*",
142-
"Resource::arn:aws:bedrock:eu-west-2:undefined:knowledge-base/*",
143-
"Resource::arn:aws:bedrock:eu-west-2:591291862413:knowledge-base/*"
135+
`Resource::arn:aws:lambda:eu-west-2:${account}:function:*`,
136+
`Resource::arn:aws:bedrock:eu-west-2:${account}:guardrail/*`,
137+
`Resource::arn:aws:bedrock:eu-west-2:${account}:knowledge-base/*`
144138
]
145139
}
146140
]

0 commit comments

Comments
 (0)