12
12
*/
13
13
14
14
// Imports
15
- import { Aws , App , Stack } from "@aws-cdk/core" ;
15
+ import { Aws , App , Stack , RemovalPolicy } from "@aws-cdk/core" ;
16
16
import { FargateToS3 , FargateToS3Props } from "../lib" ;
17
17
import { generateIntegStackName , getTestVpc , CreateFargateService } from '@aws-solutions-constructs/core' ;
18
18
import * as ecs from '@aws-cdk/aws-ecs' ;
19
19
import * as s3 from '@aws-cdk/aws-s3' ;
20
+ import * as defaults from '@aws-solutions-constructs/core' ;
20
21
21
22
// Setup
22
23
const app = new App ( ) ;
@@ -26,7 +27,16 @@ const stack = new Stack(app, generateIntegStackName(__filename), {
26
27
stack . templateOptions . description = 'Integration Test with new VPC, Service and Bucket' ;
27
28
28
29
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
+ ] ) ;
30
40
31
41
const image = ecs . ContainerImage . fromRegistry ( 'nginx' ) ;
32
42
@@ -48,10 +58,14 @@ const testProps: FargateToS3Props = {
48
58
existingFargateServiceObject : testService ,
49
59
bucketArnEnvironmentVariableName : 'CUSTOM_ARN' ,
50
60
bucketEnvironmentVariableName : 'CUSTOM_NAME' ,
51
- bucketPermissions : [ 'Delete' , 'Put' , 'ReadWrite' ]
61
+ bucketPermissions : [ 'Delete' , 'Put' , 'ReadWrite' ] ,
62
+
52
63
} ;
53
64
54
65
new FargateToS3 ( stack , 'test-construct' , testProps ) ;
55
66
67
+
68
+
69
+
56
70
// Synth
57
71
app . synth ( ) ;
0 commit comments