|
| 1 | + |
| 2 | +import {Stack} from "aws-cdk-lib" |
| 3 | +import {NagPackSuppression, NagSuppressions} from "cdk-nag" |
| 4 | + |
| 5 | +export const nagSuppressions = (stack: Stack) => { |
| 6 | + safeAddNagSuppression( |
| 7 | + stack, |
| 8 | + "/VpcResourcesStack/ECRDockerEndpoint-tags/CustomResourcePolicy/Resource", |
| 9 | + [ |
| 10 | + { |
| 11 | + id: "AwsSolutions-IAM5", |
| 12 | + reason: "Suppress error for wildcard permissions. This is fine here" |
| 13 | + } |
| 14 | + ] |
| 15 | + ) |
| 16 | + |
| 17 | + safeAddNagSuppression( |
| 18 | + stack, |
| 19 | + "/VpcResourcesStack/AWS679f53fac002430cb0da5b7982bd2287/ServiceRole/Resource", |
| 20 | + [ |
| 21 | + { |
| 22 | + id: "AwsSolutions-IAM4", |
| 23 | + reason: "Suppress error for using AWS managed policy. This is fine here" |
| 24 | + } |
| 25 | + ] |
| 26 | + ) |
| 27 | + |
| 28 | + safeAddNagSuppression( |
| 29 | + stack, |
| 30 | + "/VpcResourcesStack/AWS679f53fac002430cb0da5b7982bd2287/Resource", |
| 31 | + [ |
| 32 | + { |
| 33 | + id: "AwsSolutions-L1", |
| 34 | + reason: "Suppress error for using not using latest runtime. This is fine here" |
| 35 | + } |
| 36 | + ] |
| 37 | + ) |
| 38 | + |
| 39 | + safeAddNagSuppression( |
| 40 | + stack, |
| 41 | + "/VpcResourcesStack/ECREndpoint-tags/CustomResourcePolicy/Resource", |
| 42 | + [ |
| 43 | + { |
| 44 | + id: "AwsSolutions-IAM5", |
| 45 | + reason: "Suppress error for wildcard permissions. This is fine here" |
| 46 | + } |
| 47 | + ] |
| 48 | + ) |
| 49 | + |
| 50 | + safeAddNagSuppression( |
| 51 | + stack, |
| 52 | + "/VpcResourcesStack/SecretManagerEndpoint-tags/CustomResourcePolicy/Resource", |
| 53 | + [ |
| 54 | + { |
| 55 | + id: "AwsSolutions-IAM5", |
| 56 | + reason: "Suppress error for wildcard permissions. This is fine here" |
| 57 | + } |
| 58 | + ] |
| 59 | + ) |
| 60 | + |
| 61 | + safeAddNagSuppression( |
| 62 | + stack, |
| 63 | + "/VpcResourcesStack/CloudWatchEndpoint-tags/CustomResourcePolicy/Resource", |
| 64 | + [ |
| 65 | + { |
| 66 | + id: "AwsSolutions-IAM5", |
| 67 | + reason: "Suppress error for wildcard permissions. This is fine here" |
| 68 | + } |
| 69 | + ] |
| 70 | + ) |
| 71 | + |
| 72 | + safeAddNagSuppression( |
| 73 | + stack, |
| 74 | + "/VpcResourcesStack/CloudWatchLogsEndpoint-tags/CustomResourcePolicy/Resource", |
| 75 | + [ |
| 76 | + { |
| 77 | + id: "AwsSolutions-IAM5", |
| 78 | + reason: "Suppress error for wildcard permissions. This is fine here" |
| 79 | + } |
| 80 | + ] |
| 81 | + ) |
| 82 | + |
| 83 | + safeAddNagSuppression( |
| 84 | + stack, |
| 85 | + "/VpcResourcesStack/CloudWatchEventsEndpoint-tags/CustomResourcePolicy/Resource", |
| 86 | + [ |
| 87 | + { |
| 88 | + id: "AwsSolutions-IAM5", |
| 89 | + reason: "Suppress error for wildcard permissions. This is fine here" |
| 90 | + } |
| 91 | + ] |
| 92 | + ) |
| 93 | + |
| 94 | + safeAddNagSuppression( |
| 95 | + stack, |
| 96 | + "/VpcResourcesStack/SSMEndpoint-tags/CustomResourcePolicy/Resource", |
| 97 | + [ |
| 98 | + { |
| 99 | + id: "AwsSolutions-IAM5", |
| 100 | + reason: "Suppress error for wildcard permissions. This is fine here" |
| 101 | + } |
| 102 | + ] |
| 103 | + ) |
| 104 | + |
| 105 | +} |
| 106 | + |
| 107 | +const safeAddNagSuppression = (stack: Stack, path: string, suppressions: Array<NagPackSuppression>) => { |
| 108 | + try { |
| 109 | + NagSuppressions.addResourceSuppressionsByPath(stack, path, suppressions) |
| 110 | + |
| 111 | + // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 112 | + } catch(err){ |
| 113 | + console.log(`Could not find path ${path}`) |
| 114 | + } |
| 115 | +} |
0 commit comments