Skip to content

Commit

Permalink
WIP: cdk-nag
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed Oct 29, 2023
1 parent fb583d4 commit 82e1484
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions cdk/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
Expand Down
15 changes: 15 additions & 0 deletions cdk/lib/app-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ISecret } from 'aws-cdk-lib/aws-secretsmanager';
import { SecretValue } from 'aws-cdk-lib';

import { AppProps } from './types';
import { NagSuppressions } from 'cdk-nag';

export class AppStack extends cdk.Stack {
constructor(scope: Construct, id: string, appProps: AppProps, props?: cdk.StackProps) {
Expand Down Expand Up @@ -61,6 +62,10 @@ export class AppStack extends cdk.Stack {
subnets: dataSubnets,
},
});
NagSuppressions.addResourceSuppressions(
db,
[{ id: 'AwsSolutions-RDS3', reason: 'Single AZ app, HA not needed' }],
);

// ////////////////////////
// ECS Cluster
Expand Down Expand Up @@ -284,6 +289,11 @@ export class AppStack extends cdk.Stack {
actions: ['ses:SendRawEmail'],
resources: ['*'],
}));
NagSuppressions.addResourceSuppressions(
jobsTaskDefinition,
[{ id: 'AwsSolutions-IAM5', reason: 'SES has no resources', appliesTo: ['Resource::*'] }],
true,
);

const jobsService = new ecs.Ec2Service(this, 'JobsService', {
serviceName: 'jobs',
Expand Down Expand Up @@ -403,5 +413,10 @@ export class AppStack extends cdk.Stack {
backup.BackupResource.fromRdsDatabaseInstance(db),
],
});
NagSuppressions.addResourceSuppressions(
plan,
[{ id: 'AwsSolutions-IAM4', reason: 'Managed Policy is fine', appliesTo: ['Policy::arn:<AWS::Partition>:iam::aws:policy/service-role/AWSBackupServiceRolePolicyForBackup'] }],
true,
);
}
}
2 changes: 2 additions & 0 deletions cdk/lib/main-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export class MainStack extends cdk.Stack {
'*',
],
}],
serverAccessLogsBucket: metaBucket,
serverAccessLogsPrefix: `s3-access-logs/${appName}-catalog-${env}`,
});
}
}

0 comments on commit 82e1484

Please sign in to comment.