import * as cdk from "@aws-cdk/core" ; import * as s3 from '@aws-cdk/aws-s3' ; import { Policy , PolicyInterface } from '../../lib/policy' ; import { Reportable } from '../../lib/reporter' ; cloudformationResource see https export class BucketVersioningPolicy extends Policy implements PolicyInterface { public policyName = 'Bucket Versioning' ; public description = 'This ensures that a bucket is properly versioned' ; public link = 'https//docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-versioningconfig.html' ; public scope = s3 . CfnBucket ; public validator ( node , reporter ) { if ( ! node . versioningConfiguration || ( ! cdk . Tokenization . isResolvable ( node . versioningConfiguration ) && node . versioningConfiguration . status !== 'Enabled' ) ) { reporter . addWarning ( node , this , 'Bucket versioning is not enabled' ) ; } } } cloudformationResource see https export class BucketEncryptionPolicy extends Policy implements PolicyInterface { public policyName = 'Bucket Encryption' ; public description = 'This Policy ensures that a bucket is properly encrypted' ; public link = 'https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-bucketencryption.html' ; public scope = s3 . CfnBucket ; public validator ( node , reporter ) { if ( ! node . bucketEncryption || ( ! cdk . Tokenization . isResolvable ( node . bucketEncryption ) ) ) { reporter . addError ( node , this , 'Bucket encryption is not enabled. Please consider to add encryption' ) ; } } }