Skip to content

Commit aec48ca

Browse files
committed
added cfn suppress in integ test
1 parent 6265f15 commit aec48ca

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

source/patterns/@aws-solutions-constructs/aws-fargate-s3/test/integ.existing-resources.expected.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,17 @@
762762
"testbucketE6E05ABE": {
763763
"Type": "AWS::S3::Bucket",
764764
"UpdateReplacePolicy": "Retain",
765-
"DeletionPolicy": "Retain"
765+
"DeletionPolicy": "Retain",
766+
"Metadata": {
767+
"cfn_nag": {
768+
"rules_to_suppress": [
769+
{
770+
"id": "W35",
771+
"reason": "This S3 bucket is created for unit/ integration testing purposes only."
772+
}
773+
]
774+
}
775+
}
766776
},
767777
"existingresourcesECRAPIsecuritygroup78294485": {
768778
"Type": "AWS::EC2::SecurityGroup",

source/patterns/@aws-solutions-constructs/aws-fargate-s3/test/integ.existing-resources.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
*/
1313

1414
// Imports
15-
import { Aws, App, Stack } from "@aws-cdk/core";
15+
import { Aws, App, Stack, RemovalPolicy } from "@aws-cdk/core";
1616
import { FargateToS3, FargateToS3Props } from "../lib";
1717
import { generateIntegStackName, getTestVpc, CreateFargateService } from '@aws-solutions-constructs/core';
1818
import * as ecs from '@aws-cdk/aws-ecs';
1919
import * as s3 from '@aws-cdk/aws-s3';
20+
import * as defaults from '@aws-solutions-constructs/core';
2021

2122
// Setup
2223
const app = new App();
@@ -26,7 +27,16 @@ const stack = new Stack(app, generateIntegStackName(__filename), {
2627
stack.templateOptions.description = 'Integration Test with new VPC, Service and Bucket';
2728

2829
const existingVpc = getTestVpc(stack);
29-
const existingBucket = new s3.Bucket(stack, 'test-bucket', {});
30+
const existingBucket = new s3.Bucket(stack, 'test-bucket', {
31+
removalPolicy: RemovalPolicy.RETAIN,
32+
});
33+
34+
const s3Bucket = existingBucket as s3.Bucket;
35+
36+
defaults.addCfnSuppressRules(s3Bucket, [
37+
{ id: 'W35',
38+
reason: 'This S3 bucket is created for unit/ integration testing purposes only.' },
39+
]);
3040

3141
const image = ecs.ContainerImage.fromRegistry('nginx');
3242

@@ -48,10 +58,14 @@ const testProps: FargateToS3Props = {
4858
existingFargateServiceObject: testService,
4959
bucketArnEnvironmentVariableName: 'CUSTOM_ARN',
5060
bucketEnvironmentVariableName: 'CUSTOM_NAME',
51-
bucketPermissions: ['Delete', 'Put', 'ReadWrite']
61+
bucketPermissions: ['Delete', 'Put', 'ReadWrite'],
62+
5263
};
5364

5465
new FargateToS3(stack, 'test-construct', testProps);
5566

67+
68+
69+
5670
// Synth
5771
app.synth();

0 commit comments

Comments
 (0)