@gradientedge/cdk-utils 5.12.0 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,6 @@ import * as logs from 'aws-cdk-lib/aws-logs';
9
9
  import * as route53 from 'aws-cdk-lib/aws-route53';
10
10
  import * as s3 from 'aws-cdk-lib/aws-s3';
11
11
  import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
12
- import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
13
12
  import { Construct } from 'constructs';
14
13
  import { CommonConstruct } from '../../common';
15
14
  import { SiteWithEcsBackendProps } from '../../types';
@@ -62,7 +61,6 @@ export declare class SiteWithEcsBackend extends CommonConstruct {
62
61
  siteDomainNames: string[];
63
62
  siteCloudfrontFunction: cloudfront.Function;
64
63
  siteFunctionAssociations: cloudfront.FunctionAssociation[];
65
- siteWebAcl: wafv2.CfnWebACL;
66
64
  constructor(parent: Construct, id: string, props: SiteWithEcsBackendProps);
67
65
  /**
68
66
  * @summary Initialise and provision resources
@@ -151,11 +149,6 @@ export declare class SiteWithEcsBackend extends CommonConstruct {
151
149
  * @protected
152
150
  */
153
151
  protected resolveSiteFunctionAssociations(): void;
154
- /**
155
- * @summary Method to create WAF
156
- * @protected
157
- */
158
- protected createSiteWebAcl(): void;
159
152
  /**
160
153
  * Method to create Site distribution
161
154
  * @protected
@@ -80,7 +80,6 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
80
80
  siteDomainNames;
81
81
  siteCloudfrontFunction;
82
82
  siteFunctionAssociations;
83
- siteWebAcl;
84
83
  constructor(parent, id, props) {
85
84
  super(parent, id, props);
86
85
  this.props = props;
@@ -108,7 +107,6 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
108
107
  this.createSiteOrigin();
109
108
  this.createSiteCloudfrontFunction();
110
109
  this.resolveSiteFunctionAssociations();
111
- this.createSiteWebAcl();
112
110
  this.createDistribution();
113
111
  this.createNetworkMappings();
114
112
  this.invalidateDistributionCache();
@@ -307,21 +305,12 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
307
305
  ];
308
306
  }
309
307
  }
310
- /**
311
- * @summary Method to create WAF
312
- * @protected
313
- */
314
- createSiteWebAcl() {
315
- if (!this.props.siteWebAcl)
316
- throw 'SiteWebAcl props undefined';
317
- this.siteWebAcl = this.wafManager.createWebAcl(`${this.id}-waf`, this, this.props.siteWebAcl);
318
- }
319
308
  /**
320
309
  * Method to create Site distribution
321
310
  * @protected
322
311
  */
323
312
  createDistribution() {
324
- this.siteDistribution = this.cloudFrontManager.createDistributionWithHttpOrigin(`${this.id}-distribution`, this, this.props.siteDistribution, this.siteOrigin, this.siteDomainNames, this.siteLogBucket, this.siteCertificate, this.siteFunctionAssociations, this.siteWebAcl.attrId);
313
+ this.siteDistribution = this.cloudFrontManager.createDistributionWithHttpOrigin(`${this.id}-distribution`, this, this.props.siteDistribution, this.siteOrigin, this.siteDomainNames, this.siteLogBucket, this.siteCertificate, this.siteFunctionAssociations);
325
314
  }
326
315
  /**
327
316
  * Method to create Route53 records for distribution
@@ -3,7 +3,6 @@ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
3
3
  import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
4
4
  import * as route53 from 'aws-cdk-lib/aws-route53';
5
5
  import * as s3 from 'aws-cdk-lib/aws-s3';
6
- import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
7
6
  import { Construct } from 'constructs';
8
7
  import { CommonConstruct } from '../../common';
9
8
  import { StaticSiteProps } from '../../types';
@@ -40,7 +39,6 @@ export declare class StaticSite extends CommonConstruct {
40
39
  siteOriginAccessIdentity: cloudfront.OriginAccessIdentity;
41
40
  siteCloudfrontFunction: cloudfront.Function;
42
41
  siteFunctionAssociations: cloudfront.FunctionAssociation[];
43
- siteWebAcl: wafv2.CfnWebACL;
44
42
  constructor(parent: Construct, id: string, props: StaticSiteProps);
45
43
  /**
46
44
  * @summary Initialise and provision resources
@@ -78,11 +76,6 @@ export declare class StaticSite extends CommonConstruct {
78
76
  * @protected
79
77
  */
80
78
  protected resolveSiteFunctionAssociations(): void;
81
- /**
82
- * @summary Method to create WAF
83
- * @protected
84
- */
85
- protected createSiteWebAcl(): void;
86
79
  /**
87
80
  * @summary Method to create a site cloudfront distribution
88
81
  * @protected
@@ -62,7 +62,6 @@ class StaticSite extends common_1.CommonConstruct {
62
62
  siteOriginAccessIdentity;
63
63
  siteCloudfrontFunction;
64
64
  siteFunctionAssociations;
65
- siteWebAcl;
66
65
  constructor(parent, id, props) {
67
66
  super(parent, id, props);
68
67
  this.props = props;
@@ -80,7 +79,6 @@ class StaticSite extends common_1.CommonConstruct {
80
79
  this.createSiteOrigin();
81
80
  this.createSiteCloudfrontFunction();
82
81
  this.resolveSiteFunctionAssociations();
83
- this.createSiteWebAcl();
84
82
  this.createSiteDistribution();
85
83
  this.createSiteRouteAssets();
86
84
  this.deploySite();
@@ -144,15 +142,6 @@ class StaticSite extends common_1.CommonConstruct {
144
142
  ];
145
143
  }
146
144
  }
147
- /**
148
- * @summary Method to create WAF
149
- * @protected
150
- */
151
- createSiteWebAcl() {
152
- if (!this.props.siteWebAcl)
153
- throw 'SiteWebAcl props undefined';
154
- this.siteWebAcl = this.wafManager.createWebAcl(`${this.id}-waf`, this, this.props.siteWebAcl);
155
- }
156
145
  /**
157
146
  * @summary Method to create a site cloudfront distribution
158
147
  * @protected
@@ -160,7 +149,7 @@ class StaticSite extends common_1.CommonConstruct {
160
149
  createSiteDistribution() {
161
150
  if (!this.props.siteDistribution)
162
151
  throw 'SiteDistribution props undefined';
163
- this.siteDistribution = this.cloudFrontManager.createDistributionWithS3Origin(`${this.id}-distribution`, this, this.props.siteDistribution, this.siteOrigin, this.siteBucket, this.siteLogBucket, this.siteOriginAccessIdentity, this.siteCertificate, this.props.siteAliases, this.siteFunctionAssociations, this.siteWebAcl.attrId);
152
+ this.siteDistribution = this.cloudFrontManager.createDistributionWithS3Origin(`${this.id}-distribution`, this, this.props.siteDistribution, this.siteOrigin, this.siteBucket, this.siteLogBucket, this.siteOriginAccessIdentity, this.siteCertificate, this.props.siteAliases, this.siteFunctionAssociations);
164
153
  }
165
154
  /**
166
155
  * @summary Method to create route53 records for static site
@@ -49,9 +49,8 @@ export declare class CloudFrontManager {
49
49
  * @param {cloudfront.OriginAccessIdentity?} oai
50
50
  * @param {acm.ICertificate?} certificate
51
51
  * @param {string[]?} aliases
52
- * @param {string?} webAclId
53
52
  */
54
- createCloudFrontDistribution(id: string, scope: common.CommonConstruct, props: types.CloudFrontProps, siteBucket?: s3.IBucket, logBucket?: s3.IBucket, oai?: cloudfront.OriginAccessIdentity, certificate?: acm.ICertificate, aliases?: string[], webAclId?: string): cdk.aws_cloudfront.CloudFrontWebDistribution;
53
+ createCloudFrontDistribution(id: string, scope: common.CommonConstruct, props: types.CloudFrontProps, siteBucket?: s3.IBucket, logBucket?: s3.IBucket, oai?: cloudfront.OriginAccessIdentity, certificate?: acm.ICertificate, aliases?: string[]): cdk.aws_cloudfront.CloudFrontWebDistribution;
55
54
  /**
56
55
  * Method to create a CloudFront distribution with S3 Origin
57
56
  * @param {string} id scoped id of the resource
@@ -64,9 +63,8 @@ export declare class CloudFrontManager {
64
63
  * @param {acm.ICertificate?} certificate
65
64
  * @param {string[]?} aliases
66
65
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
67
- * @param {string?} webAclId
68
66
  */
69
- createDistributionWithS3Origin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.S3Origin, siteBucket: s3.IBucket, logBucket?: s3.IBucket, oai?: cloudfront.OriginAccessIdentity, certificate?: acm.ICertificate, aliases?: string[], defaultFunctionAssociations?: cloudfront.FunctionAssociation[], webAclId?: string): cdk.aws_cloudfront.Distribution;
67
+ createDistributionWithS3Origin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.S3Origin, siteBucket: s3.IBucket, logBucket?: s3.IBucket, oai?: cloudfront.OriginAccessIdentity, certificate?: acm.ICertificate, aliases?: string[], defaultFunctionAssociations?: cloudfront.FunctionAssociation[]): cdk.aws_cloudfront.Distribution;
70
68
  /**
71
69
  * Method to create a CloudFront distribution with HTTP Origin
72
70
  * @param {string} id scoped id of the resource
@@ -77,9 +75,8 @@ export declare class CloudFrontManager {
77
75
  * @param {s3.IBucket?} logBucket
78
76
  * @param {acm.ICertificate?} certificate
79
77
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
80
- * @param {string?} webAclId
81
78
  */
82
- createDistributionWithHttpOrigin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.HttpOrigin, domainNames: string[], logBucket?: s3.IBucket, certificate?: acm.ICertificate, defaultFunctionAssociations?: cloudfront.FunctionAssociation[], webAclId?: string): cdk.aws_cloudfront.Distribution;
79
+ createDistributionWithHttpOrigin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.HttpOrigin, domainNames: string[], logBucket?: s3.IBucket, certificate?: acm.ICertificate, defaultFunctionAssociations?: cloudfront.FunctionAssociation[]): cdk.aws_cloudfront.Distribution;
83
80
  /**
84
81
  * @summary Method to provision a Lambda@Edge function
85
82
  *
@@ -78,9 +78,8 @@ class CloudFrontManager {
78
78
  * @param {cloudfront.OriginAccessIdentity?} oai
79
79
  * @param {acm.ICertificate?} certificate
80
80
  * @param {string[]?} aliases
81
- * @param {string?} webAclId
82
81
  */
83
- createCloudFrontDistribution(id, scope, props, siteBucket, logBucket, oai, certificate, aliases, webAclId) {
82
+ createCloudFrontDistribution(id, scope, props, siteBucket, logBucket, oai, certificate, aliases) {
84
83
  if (!siteBucket)
85
84
  throw `SiteBucket not defined`;
86
85
  if (!certificate)
@@ -114,7 +113,7 @@ class CloudFrontManager {
114
113
  securityPolicy: cloudfront.SecurityPolicyProtocol.TLS_V1_1_2016,
115
114
  sslMethod: cloudfront.SSLMethod.SNI,
116
115
  }),
117
- webACLId: webAclId,
116
+ webACLId: props.webACLId,
118
117
  });
119
118
  utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId);
120
119
  utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName);
@@ -132,9 +131,8 @@ class CloudFrontManager {
132
131
  * @param {acm.ICertificate?} certificate
133
132
  * @param {string[]?} aliases
134
133
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
135
- * @param {string?} webAclId
136
134
  */
137
- createDistributionWithS3Origin(id, scope, props, origin, siteBucket, logBucket, oai, certificate, aliases, defaultFunctionAssociations, webAclId) {
135
+ createDistributionWithS3Origin(id, scope, props, origin, siteBucket, logBucket, oai, certificate, aliases, defaultFunctionAssociations) {
138
136
  const distribution = new cloudfront.Distribution(scope, `${id}`, {
139
137
  certificate: certificate,
140
138
  comment: `${id} - ${scope.props.stage} stage`,
@@ -159,7 +157,7 @@ class CloudFrontManager {
159
157
  logFilePrefix: props.logFilePrefix ?? `edge/`,
160
158
  minimumProtocolVersion: props.minimumProtocolVersion ?? cloudfront.SecurityPolicyProtocol.TLS_V1_2_2021,
161
159
  priceClass: props.priceClass ?? cloudfront.PriceClass.PRICE_CLASS_ALL,
162
- webAclId: webAclId,
160
+ webAclId: props.webAclId,
163
161
  });
164
162
  utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId);
165
163
  utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName);
@@ -175,9 +173,8 @@ class CloudFrontManager {
175
173
  * @param {s3.IBucket?} logBucket
176
174
  * @param {acm.ICertificate?} certificate
177
175
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
178
- * @param {string?} webAclId
179
176
  */
180
- createDistributionWithHttpOrigin(id, scope, props, origin, domainNames, logBucket, certificate, defaultFunctionAssociations, webAclId) {
177
+ createDistributionWithHttpOrigin(id, scope, props, origin, domainNames, logBucket, certificate, defaultFunctionAssociations) {
181
178
  const distribution = new cloudfront.Distribution(scope, `${id}`, {
182
179
  certificate: certificate,
183
180
  comment: `${id} - ${scope.props.stage} stage`,
@@ -202,7 +199,7 @@ class CloudFrontManager {
202
199
  logFilePrefix: props.logFilePrefix ?? `edge/`,
203
200
  minimumProtocolVersion: props.minimumProtocolVersion ?? cloudfront.SecurityPolicyProtocol.TLS_V1_2_2021,
204
201
  priceClass: props.priceClass ?? cloudfront.PriceClass.PRICE_CLASS_ALL,
205
- webAclId: webAclId,
202
+ webAclId: props.webAclId,
206
203
  });
207
204
  utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId);
208
205
  utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName);
@@ -58,12 +58,17 @@ class SqsManager {
58
58
  createQueue(id, scope, props, deadLetterQueue) {
59
59
  if (!props)
60
60
  throw `Queue props undefined`;
61
+ console.log(props);
61
62
  const queue = new sqs.Queue(scope, id, {
62
63
  queueName: props.queueName,
63
- visibilityTimeout: cdk.Duration.seconds(props.visibilityTimeoutInSecs),
64
- receiveMessageWaitTime: cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs),
64
+ visibilityTimeout: props.visibilityTimeoutInSecs
65
+ ? cdk.Duration.seconds(props.visibilityTimeoutInSecs)
66
+ : undefined,
67
+ receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
68
+ ? cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs)
69
+ : undefined,
65
70
  contentBasedDeduplication: props.contentBasedDeduplication,
66
- dataKeyReuse: cdk.Duration.seconds(props.dataKeyReuseInSecs),
71
+ dataKeyReuse: props.dataKeyReuseInSecs ? cdk.Duration.seconds(props.dataKeyReuseInSecs) : undefined,
67
72
  deadLetterQueue: !deadLetterQueue
68
73
  ? undefined
69
74
  : {
@@ -71,7 +76,7 @@ class SqsManager {
71
76
  maxReceiveCount: props.maxReceiveCount,
72
77
  },
73
78
  deduplicationScope: props.deduplicationScope,
74
- deliveryDelay: cdk.Duration.seconds(props.deliveryDelayInSecs),
79
+ deliveryDelay: props.deliveryDelayInSecs ? cdk.Duration.seconds(props.deliveryDelayInSecs) : undefined,
75
80
  encryption: props.encryption,
76
81
  encryptionMasterKey: props.encryptionMasterKey,
77
82
  fifo: props.fifo,
@@ -92,10 +97,9 @@ class SqsManager {
92
97
  * @param {types.LambdaProps} props the lambda properties
93
98
  */
94
99
  createRedriveQueueForLambda(id, scope, props) {
95
- if (!props.dlq || !props.redriveq)
100
+ if (!props.redriveq)
96
101
  throw `Redrive queue props for Lambda undefined`;
97
102
  return this.createQueue(`${id}`, scope, {
98
- ...props.dlq,
99
103
  ...props.redriveq,
100
104
  ...{
101
105
  queueName: `${props.functionName}-redriveq-${scope.props.stage}`,
@@ -72,7 +72,6 @@ export interface SiteWithEcsBackendProps extends CommonStackProps {
72
72
  siteSubDomain: string;
73
73
  siteTask: ecsPatterns.ApplicationLoadBalancedFargateServiceProps;
74
74
  siteVpc: ec2.VpcProps;
75
- siteWebAcl?: WafWebACLProps;
76
75
  useExistingHostedZone: boolean;
77
76
  nodeEnv: string;
78
77
  logLevel: string;
@@ -95,7 +94,6 @@ export interface StaticSiteProps extends CommonStackProps {
95
94
  siteRecordName?: string;
96
95
  siteSubDomain?: string;
97
96
  siteAliases?: string[];
98
- siteWebAcl?: WafWebACLProps;
99
97
  useExistingHostedZone: boolean;
100
98
  nodeEnv: string;
101
99
  logLevel: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "5.12.0",
3
+ "version": "5.13.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -46,52 +46,52 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@types/lodash": "^4.14.182",
49
- "@types/node": "^18.0.0",
49
+ "@types/node": "^18.6.1",
50
50
  "app-root-path": "^3.0.0",
51
- "aws-cdk-lib": "^2.28.1",
52
- "aws-sdk": "^2.1158.0",
53
- "constructs": "^10.1.42",
51
+ "aws-cdk-lib": "^2.33.0",
52
+ "aws-sdk": "^2.1182.0",
53
+ "constructs": "^10.1.58",
54
54
  "lodash": "^4.17.21",
55
- "moment": "^2.29.3",
55
+ "moment": "^2.29.4",
56
56
  "nconf": "^0.12.0",
57
57
  "pluralize": "^8.0.0",
58
- "ts-node": "^10.8.1"
58
+ "ts-node": "^10.9.1"
59
59
  },
60
60
  "devDependencies": {
61
- "@babel/plugin-proposal-class-properties": "^7.17.12",
62
- "@types/jest": "^28.1.2",
63
- "@typescript-eslint/eslint-plugin": "^5.29.0",
64
- "@typescript-eslint/parser": "^5.29.0",
61
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
62
+ "@types/jest": "^28.1.6",
63
+ "@typescript-eslint/eslint-plugin": "^5.31.0",
64
+ "@typescript-eslint/parser": "^5.31.0",
65
65
  "aws-cdk": "*",
66
66
  "babel-eslint": "^10.1.0",
67
67
  "better-docs": "^2.7.2",
68
68
  "codecov": "^3.8.3",
69
- "commitizen": "^4.2.4",
69
+ "commitizen": "^4.2.5",
70
70
  "dotenv": "^16.0.1",
71
- "eslint": "^8.18.0",
71
+ "eslint": "^8.20.0",
72
72
  "eslint-config-prettier": "^8.5.0",
73
73
  "eslint-plugin-import": "^2.26.0",
74
74
  "husky": "^8.0.1",
75
- "jest": "^28.1.1",
76
- "jest-extended": "^2.0.0",
77
- "jest-junit": "^13.2.0",
78
- "jsdoc": "^3.6.10",
75
+ "jest": "^28.1.3",
76
+ "jest-extended": "^3.0.1",
77
+ "jest-junit": "^14.0.0",
78
+ "jsdoc": "^3.6.11",
79
79
  "jsdoc-babel": "^0.5.0",
80
80
  "jsdoc-mermaid": "^1.0.0",
81
- "lerna": "^5.1.4",
81
+ "lerna": "^5.3.0",
82
82
  "prettier": "^2.7.1",
83
83
  "prettier-plugin-organize-imports": "^3.0.0",
84
84
  "rimraf": "^3.0.2",
85
85
  "semantic-release": "^19.0.3",
86
- "ts-jest": "^28.0.5",
87
- "ts-node": "^10.8.1",
86
+ "ts-jest": "^28.0.7",
87
+ "ts-node": "^10.9.1",
88
88
  "typescript": "4.7.4"
89
89
  },
90
90
  "optionalDependencies": {
91
- "@babel/core": "^7.18.5",
91
+ "@babel/core": "^7.18.9",
92
92
  "prop-types": "^15.8.1",
93
- "react": "^17.0.2",
94
- "react-dom": "^17.0.2"
93
+ "react": "^18.2.0",
94
+ "react-dom": "^18.2.0"
95
95
  },
96
96
  "config": {
97
97
  "commitizen": {
@@ -11,7 +11,6 @@ import * as logs from 'aws-cdk-lib/aws-logs'
11
11
  import * as route53 from 'aws-cdk-lib/aws-route53'
12
12
  import * as s3 from 'aws-cdk-lib/aws-s3'
13
13
  import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager'
14
- import * as wafv2 from 'aws-cdk-lib/aws-wafv2'
15
14
  import { Construct } from 'constructs'
16
15
  import { CommonConstruct } from '../../common'
17
16
  import { SiteWithEcsBackendProps } from '../../types'
@@ -66,7 +65,6 @@ export class SiteWithEcsBackend extends CommonConstruct {
66
65
  siteDomainNames: string[]
67
66
  siteCloudfrontFunction: cloudfront.Function
68
67
  siteFunctionAssociations: cloudfront.FunctionAssociation[]
69
- siteWebAcl: wafv2.CfnWebACL
70
68
 
71
69
  constructor(parent: Construct, id: string, props: SiteWithEcsBackendProps) {
72
70
  super(parent, id, props)
@@ -97,7 +95,6 @@ export class SiteWithEcsBackend extends CommonConstruct {
97
95
  this.createSiteOrigin()
98
96
  this.createSiteCloudfrontFunction()
99
97
  this.resolveSiteFunctionAssociations()
100
- this.createSiteWebAcl()
101
98
  this.createDistribution()
102
99
  this.createNetworkMappings()
103
100
  this.invalidateDistributionCache()
@@ -342,16 +339,6 @@ export class SiteWithEcsBackend extends CommonConstruct {
342
339
  }
343
340
  }
344
341
 
345
- /**
346
- * @summary Method to create WAF
347
- * @protected
348
- */
349
- protected createSiteWebAcl() {
350
- if (!this.props.siteWebAcl) throw 'SiteWebAcl props undefined'
351
-
352
- this.siteWebAcl = this.wafManager.createWebAcl(`${this.id}-waf`, this, this.props.siteWebAcl)
353
- }
354
-
355
342
  /**
356
343
  * Method to create Site distribution
357
344
  * @protected
@@ -365,8 +352,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
365
352
  this.siteDomainNames,
366
353
  this.siteLogBucket,
367
354
  this.siteCertificate,
368
- this.siteFunctionAssociations,
369
- this.siteWebAcl.attrId
355
+ this.siteFunctionAssociations
370
356
  )
371
357
  }
372
358
 
@@ -3,7 +3,6 @@ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'
3
3
  import * as origins from 'aws-cdk-lib/aws-cloudfront-origins'
4
4
  import * as route53 from 'aws-cdk-lib/aws-route53'
5
5
  import * as s3 from 'aws-cdk-lib/aws-s3'
6
- import * as wafv2 from 'aws-cdk-lib/aws-wafv2'
7
6
  import { Construct } from 'constructs'
8
7
  import { CommonConstruct } from '../../common'
9
8
  import { StaticSiteProps } from '../../types'
@@ -44,7 +43,6 @@ export class StaticSite extends CommonConstruct {
44
43
  siteOriginAccessIdentity: cloudfront.OriginAccessIdentity
45
44
  siteCloudfrontFunction: cloudfront.Function
46
45
  siteFunctionAssociations: cloudfront.FunctionAssociation[]
47
- siteWebAcl: wafv2.CfnWebACL
48
46
 
49
47
  constructor(parent: Construct, id: string, props: StaticSiteProps) {
50
48
  super(parent, id, props)
@@ -65,7 +63,6 @@ export class StaticSite extends CommonConstruct {
65
63
  this.createSiteOrigin()
66
64
  this.createSiteCloudfrontFunction()
67
65
  this.resolveSiteFunctionAssociations()
68
- this.createSiteWebAcl()
69
66
  this.createSiteDistribution()
70
67
  this.createSiteRouteAssets()
71
68
  this.deploySite()
@@ -156,16 +153,6 @@ export class StaticSite extends CommonConstruct {
156
153
  }
157
154
  }
158
155
 
159
- /**
160
- * @summary Method to create WAF
161
- * @protected
162
- */
163
- protected createSiteWebAcl() {
164
- if (!this.props.siteWebAcl) throw 'SiteWebAcl props undefined'
165
-
166
- this.siteWebAcl = this.wafManager.createWebAcl(`${this.id}-waf`, this, this.props.siteWebAcl)
167
- }
168
-
169
156
  /**
170
157
  * @summary Method to create a site cloudfront distribution
171
158
  * @protected
@@ -183,8 +170,7 @@ export class StaticSite extends CommonConstruct {
183
170
  this.siteOriginAccessIdentity,
184
171
  this.siteCertificate,
185
172
  this.props.siteAliases,
186
- this.siteFunctionAssociations,
187
- this.siteWebAcl.attrId
173
+ this.siteFunctionAssociations
188
174
  )
189
175
  }
190
176
 
@@ -61,7 +61,6 @@ export class CloudFrontManager {
61
61
  * @param {cloudfront.OriginAccessIdentity?} oai
62
62
  * @param {acm.ICertificate?} certificate
63
63
  * @param {string[]?} aliases
64
- * @param {string?} webAclId
65
64
  */
66
65
  public createCloudFrontDistribution(
67
66
  id: string,
@@ -71,8 +70,7 @@ export class CloudFrontManager {
71
70
  logBucket?: s3.IBucket,
72
71
  oai?: cloudfront.OriginAccessIdentity,
73
72
  certificate?: acm.ICertificate,
74
- aliases?: string[],
75
- webAclId?: string
73
+ aliases?: string[]
76
74
  ) {
77
75
  if (!siteBucket) throw `SiteBucket not defined`
78
76
  if (!certificate) throw `Certificate not defined`
@@ -105,7 +103,7 @@ export class CloudFrontManager {
105
103
  securityPolicy: cloudfront.SecurityPolicyProtocol.TLS_V1_1_2016,
106
104
  sslMethod: cloudfront.SSLMethod.SNI,
107
105
  }),
108
- webACLId: webAclId,
106
+ webACLId: props.webACLId,
109
107
  })
110
108
 
111
109
  utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
@@ -126,7 +124,6 @@ export class CloudFrontManager {
126
124
  * @param {acm.ICertificate?} certificate
127
125
  * @param {string[]?} aliases
128
126
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
129
- * @param {string?} webAclId
130
127
  */
131
128
  public createDistributionWithS3Origin(
132
129
  id: string,
@@ -138,8 +135,7 @@ export class CloudFrontManager {
138
135
  oai?: cloudfront.OriginAccessIdentity,
139
136
  certificate?: acm.ICertificate,
140
137
  aliases?: string[],
141
- defaultFunctionAssociations?: cloudfront.FunctionAssociation[],
142
- webAclId?: string
138
+ defaultFunctionAssociations?: cloudfront.FunctionAssociation[]
143
139
  ) {
144
140
  const distribution = new cloudfront.Distribution(scope, `${id}`, {
145
141
  certificate: certificate,
@@ -165,7 +161,7 @@ export class CloudFrontManager {
165
161
  logFilePrefix: props.logFilePrefix ?? `edge/`,
166
162
  minimumProtocolVersion: props.minimumProtocolVersion ?? cloudfront.SecurityPolicyProtocol.TLS_V1_2_2021,
167
163
  priceClass: props.priceClass ?? cloudfront.PriceClass.PRICE_CLASS_ALL,
168
- webAclId: webAclId,
164
+ webAclId: props.webAclId,
169
165
  })
170
166
 
171
167
  utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
@@ -184,7 +180,6 @@ export class CloudFrontManager {
184
180
  * @param {s3.IBucket?} logBucket
185
181
  * @param {acm.ICertificate?} certificate
186
182
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
187
- * @param {string?} webAclId
188
183
  */
189
184
  public createDistributionWithHttpOrigin(
190
185
  id: string,
@@ -194,8 +189,7 @@ export class CloudFrontManager {
194
189
  domainNames: string[],
195
190
  logBucket?: s3.IBucket,
196
191
  certificate?: acm.ICertificate,
197
- defaultFunctionAssociations?: cloudfront.FunctionAssociation[],
198
- webAclId?: string
192
+ defaultFunctionAssociations?: cloudfront.FunctionAssociation[]
199
193
  ) {
200
194
  const distribution = new cloudfront.Distribution(scope, `${id}`, {
201
195
  certificate: certificate,
@@ -221,7 +215,7 @@ export class CloudFrontManager {
221
215
  logFilePrefix: props.logFilePrefix ?? `edge/`,
222
216
  minimumProtocolVersion: props.minimumProtocolVersion ?? cloudfront.SecurityPolicyProtocol.TLS_V1_2_2021,
223
217
  priceClass: props.priceClass ?? cloudfront.PriceClass.PRICE_CLASS_ALL,
224
- webAclId: webAclId,
218
+ webAclId: props.webAclId,
225
219
  })
226
220
 
227
221
  utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
@@ -35,12 +35,18 @@ export class SqsManager {
35
35
  public createQueue(id: string, scope: common.CommonConstruct, props: types.QueueProps, deadLetterQueue?: sqs.IQueue) {
36
36
  if (!props) throw `Queue props undefined`
37
37
 
38
+ console.log(props)
39
+
38
40
  const queue = new sqs.Queue(scope, id, {
39
41
  queueName: props.queueName,
40
- visibilityTimeout: cdk.Duration.seconds(props.visibilityTimeoutInSecs),
41
- receiveMessageWaitTime: cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs),
42
+ visibilityTimeout: props.visibilityTimeoutInSecs
43
+ ? cdk.Duration.seconds(props.visibilityTimeoutInSecs)
44
+ : undefined,
45
+ receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
46
+ ? cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs)
47
+ : undefined,
42
48
  contentBasedDeduplication: props.contentBasedDeduplication,
43
- dataKeyReuse: cdk.Duration.seconds(props.dataKeyReuseInSecs),
49
+ dataKeyReuse: props.dataKeyReuseInSecs ? cdk.Duration.seconds(props.dataKeyReuseInSecs) : undefined,
44
50
  deadLetterQueue: !deadLetterQueue
45
51
  ? undefined
46
52
  : {
@@ -48,7 +54,7 @@ export class SqsManager {
48
54
  maxReceiveCount: props.maxReceiveCount,
49
55
  },
50
56
  deduplicationScope: props.deduplicationScope,
51
- deliveryDelay: cdk.Duration.seconds(props.deliveryDelayInSecs),
57
+ deliveryDelay: props.deliveryDelayInSecs ? cdk.Duration.seconds(props.deliveryDelayInSecs) : undefined,
52
58
  encryption: props.encryption,
53
59
  encryptionMasterKey: props.encryptionMasterKey,
54
60
  fifo: props.fifo,
@@ -72,10 +78,9 @@ export class SqsManager {
72
78
  * @param {types.LambdaProps} props the lambda properties
73
79
  */
74
80
  public createRedriveQueueForLambda(id: string, scope: common.CommonConstruct, props: types.LambdaProps) {
75
- if (!props.dlq || !props.redriveq) throw `Redrive queue props for Lambda undefined`
81
+ if (!props.redriveq) throw `Redrive queue props for Lambda undefined`
76
82
 
77
83
  return this.createQueue(`${id}`, scope, {
78
- ...props.dlq,
79
84
  ...props.redriveq,
80
85
  ...{
81
86
  queueName: `${props.functionName}-redriveq-${scope.props.stage}`,
@@ -75,7 +75,6 @@ export interface SiteWithEcsBackendProps extends CommonStackProps {
75
75
  siteSubDomain: string
76
76
  siteTask: ecsPatterns.ApplicationLoadBalancedFargateServiceProps
77
77
  siteVpc: ec2.VpcProps
78
- siteWebAcl?: WafWebACLProps
79
78
  useExistingHostedZone: boolean
80
79
  nodeEnv: string
81
80
  logLevel: string
@@ -99,7 +98,6 @@ export interface StaticSiteProps extends CommonStackProps {
99
98
  siteRecordName?: string
100
99
  siteSubDomain?: string
101
100
  siteAliases?: string[]
102
- siteWebAcl?: WafWebACLProps
103
101
  useExistingHostedZone: boolean
104
102
  nodeEnv: string
105
103
  logLevel: string