Skip to content

Commit

Permalink
added cfn nag suppress rule for no logging bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
mickychetta committed Nov 17, 2021
1 parent 870e5de commit d6138a1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ mybucket = defaults.CreateScrapBucket(stack, { removalPolicy: RemovalPolicy.DEST

const _construct = new CloudFrontToS3(stack, 'test-cloudfront-s3', {
existingBucketObj: mybucket,
logS3AccessLogs: false
});

// Add Cache Policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@
}
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
"DeletionPolicy": "Delete",
"Metadata": {
"cfn_nag": {
"rules_to_suppress": [
{
"id": "W35",
"reason": "This S3 bucket is created for unit/ integration testing purposes only."
}
]
}
}
},
"testcloudfronts3S3BucketPolicy250F1F61": {
"Type": "AWS::S3::BucketPolicy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,27 @@
import { App, Stack, RemovalPolicy } from "@aws-cdk/core";
import { CloudFrontToS3 } from "../lib";
import { generateIntegStackName } from '@aws-solutions-constructs/core';
import * as s3 from "@aws-cdk/aws-s3";
import * as defaults from '@aws-solutions-constructs/core';

// Setup
const app = new App();
const stack = new Stack(app, generateIntegStackName(__filename));
stack.templateOptions.description = 'Integration Test for aws-cloudfront-s3';

new CloudFrontToS3(stack, 'test-cloudfront-s3', {
const construct = new CloudFrontToS3(stack, 'test-cloudfront-s3', {
bucketProps: {
removalPolicy: RemovalPolicy.DESTROY,
},
logS3AccessLogs: false
});

const s3Bucket = construct.s3Bucket as s3.Bucket;

defaults.addCfnSuppressRules(s3Bucket, [
{ id: 'W35',
reason: 'This S3 bucket is created for unit/ integration testing purposes only.' },
]);

// Synth
app.synth();

0 comments on commit d6138a1

Please sign in to comment.