@gradientedge/cdk-utils 8.65.0 → 8.67.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.
- package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +1 -0
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +4 -1
- package/dist/src/lib/manager/aws/lambda-manager.js +11 -0
- package/dist/src/lib/types/aws/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/lib/construct/site-with-ecs-backend/main.ts +10 -1
- package/src/lib/manager/aws/lambda-manager.ts +17 -0
- package/src/lib/types/aws/index.ts +2 -0
|
@@ -37,6 +37,7 @@ export declare class SiteWithEcsBackend extends CommonConstruct {
|
|
|
37
37
|
id: string;
|
|
38
38
|
siteHostedZone: route53.IHostedZone;
|
|
39
39
|
siteCertificate: certificateManager.ICertificate;
|
|
40
|
+
siteRegionalCertificate: certificateManager.ICertificate;
|
|
40
41
|
siteEcsPolicy: iam.PolicyDocument;
|
|
41
42
|
siteEcsRole: iam.Role;
|
|
42
43
|
siteEcsEnvironment: {
|
|
@@ -58,6 +58,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
58
58
|
/* site resources */
|
|
59
59
|
siteHostedZone;
|
|
60
60
|
siteCertificate;
|
|
61
|
+
siteRegionalCertificate;
|
|
61
62
|
siteEcsPolicy;
|
|
62
63
|
siteEcsRole;
|
|
63
64
|
siteEcsEnvironment;
|
|
@@ -131,6 +132,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
131
132
|
this.props.siteCertificate.certificateArn = this.ssmManager.readStringParameterFromRegion(`${this.id}-certificate-parameter`, this, this.props.siteCertificate.certificateSsmName, this.props.siteCertificate.certificateRegion);
|
|
132
133
|
}
|
|
133
134
|
this.siteCertificate = this.acmManager.resolveCertificate(`${this.id}-certificate`, this, this.props.siteCertificate);
|
|
135
|
+
this.siteRegionalCertificate = this.acmManager.resolveCertificate(`${this.id}-regional-certificate`, this, this.props.siteRegionalCertificate, this.siteHostedZone);
|
|
134
136
|
}
|
|
135
137
|
/**
|
|
136
138
|
* @summary Method to resolve secrets from SecretsManager
|
|
@@ -230,6 +232,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
230
232
|
serviceName: `${this.id}-${this.props.stage}`,
|
|
231
233
|
cpu: this.props.siteTask.cpu,
|
|
232
234
|
loadBalancerName: `${this.id}-${this.props.stage}`,
|
|
235
|
+
certificate: this.siteRegionalCertificate,
|
|
233
236
|
domainName: this.siteInternalDomainName,
|
|
234
237
|
domainZone: this.siteHostedZone,
|
|
235
238
|
listenerPort: this.props.siteTask.listenerPort,
|
|
@@ -340,7 +343,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
|
|
|
340
343
|
createSiteOrigin() {
|
|
341
344
|
this.siteOrigin = new origins.HttpOrigin(this.siteEcsLoadBalancer.loadBalancerDnsName, {
|
|
342
345
|
httpPort: this.props.siteTask.listenerPort,
|
|
343
|
-
protocolPolicy: cloudfront.OriginProtocolPolicy.
|
|
346
|
+
protocolPolicy: cloudfront.OriginProtocolPolicy.HTTPS_ONLY,
|
|
344
347
|
});
|
|
345
348
|
}
|
|
346
349
|
/**
|
|
@@ -27,6 +27,7 @@ exports.LambdaManager = void 0;
|
|
|
27
27
|
const cdk = __importStar(require("aws-cdk-lib"));
|
|
28
28
|
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
29
29
|
const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
|
|
30
|
+
const eventSources = __importStar(require("aws-cdk-lib/aws-lambda-event-sources"));
|
|
30
31
|
const common_1 = require("../../common");
|
|
31
32
|
const utils = __importStar(require("../../utils"));
|
|
32
33
|
const cloudfront_manager_1 = require("./cloudfront-manager");
|
|
@@ -126,6 +127,11 @@ class LambdaManager {
|
|
|
126
127
|
insightsVersion: props.insightsVersion,
|
|
127
128
|
},
|
|
128
129
|
});
|
|
130
|
+
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
131
|
+
lambdaFunction.addEventSource(new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
132
|
+
reportBatchItemFailures: true,
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
129
135
|
if (props.lambdaAliases && props.lambdaAliases.length > 0) {
|
|
130
136
|
props.lambdaAliases.forEach(alias => {
|
|
131
137
|
const aliasId = alias.id ?? `${id}-${alias.aliasName}`;
|
|
@@ -218,6 +224,11 @@ class LambdaManager {
|
|
|
218
224
|
insightsVersion: props.insightsVersion,
|
|
219
225
|
},
|
|
220
226
|
});
|
|
227
|
+
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
228
|
+
lambdaFunction.addEventSource(new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
229
|
+
reportBatchItemFailures: true,
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
221
232
|
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn);
|
|
222
233
|
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName);
|
|
223
234
|
return lambdaFunction;
|
|
@@ -69,6 +69,7 @@ export interface SiteWithEcsBackendProps extends CommonStackProps {
|
|
|
69
69
|
siteCacheInvalidationDockerFilePath?: string;
|
|
70
70
|
siteHealthCheck: HealthCheck;
|
|
71
71
|
siteCertificate: AcmProps;
|
|
72
|
+
siteRegionalCertificate: AcmProps;
|
|
72
73
|
siteCluster: EcsClusterProps;
|
|
73
74
|
siteDistribution: DistributionProps;
|
|
74
75
|
siteCloudfrontFunctionProps?: CloudfrontFunctionProps;
|
|
@@ -844,5 +845,6 @@ export interface QueueProps extends sqs.QueueProps {
|
|
|
844
845
|
deliveryDelayInSecs?: number;
|
|
845
846
|
retentionInDays?: number;
|
|
846
847
|
tags?: TagProps[];
|
|
848
|
+
retriesEnabled?: boolean;
|
|
847
849
|
}
|
|
848
850
|
export {};
|
package/package.json
CHANGED
|
@@ -43,6 +43,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
43
43
|
/* site resources */
|
|
44
44
|
siteHostedZone: route53.IHostedZone
|
|
45
45
|
siteCertificate: certificateManager.ICertificate
|
|
46
|
+
siteRegionalCertificate: certificateManager.ICertificate
|
|
46
47
|
siteEcsPolicy: iam.PolicyDocument
|
|
47
48
|
siteEcsRole: iam.Role
|
|
48
49
|
siteEcsEnvironment: { [key: string]: string }
|
|
@@ -136,6 +137,13 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
136
137
|
this,
|
|
137
138
|
this.props.siteCertificate
|
|
138
139
|
)
|
|
140
|
+
|
|
141
|
+
this.siteRegionalCertificate = this.acmManager.resolveCertificate(
|
|
142
|
+
`${this.id}-regional-certificate`,
|
|
143
|
+
this,
|
|
144
|
+
this.props.siteRegionalCertificate,
|
|
145
|
+
this.siteHostedZone
|
|
146
|
+
)
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
/**
|
|
@@ -253,6 +261,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
253
261
|
serviceName: `${this.id}-${this.props.stage}`,
|
|
254
262
|
cpu: this.props.siteTask.cpu,
|
|
255
263
|
loadBalancerName: `${this.id}-${this.props.stage}`,
|
|
264
|
+
certificate: this.siteRegionalCertificate,
|
|
256
265
|
domainName: this.siteInternalDomainName,
|
|
257
266
|
domainZone: this.siteHostedZone,
|
|
258
267
|
listenerPort: this.props.siteTask.listenerPort,
|
|
@@ -386,7 +395,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
386
395
|
protected createSiteOrigin() {
|
|
387
396
|
this.siteOrigin = new origins.HttpOrigin(this.siteEcsLoadBalancer.loadBalancerDnsName, {
|
|
388
397
|
httpPort: this.props.siteTask.listenerPort,
|
|
389
|
-
protocolPolicy: cloudfront.OriginProtocolPolicy.
|
|
398
|
+
protocolPolicy: cloudfront.OriginProtocolPolicy.HTTPS_ONLY,
|
|
390
399
|
})
|
|
391
400
|
}
|
|
392
401
|
|
|
@@ -3,6 +3,7 @@ import * as ec2 from 'aws-cdk-lib/aws-ec2'
|
|
|
3
3
|
import * as efs from 'aws-cdk-lib/aws-efs'
|
|
4
4
|
import * as iam from 'aws-cdk-lib/aws-iam'
|
|
5
5
|
import * as lambda from 'aws-cdk-lib/aws-lambda'
|
|
6
|
+
import * as eventSources from 'aws-cdk-lib/aws-lambda-event-sources'
|
|
6
7
|
import * as common from '../../common'
|
|
7
8
|
import { CommonStack } from '../../common'
|
|
8
9
|
import * as types from '../../types'
|
|
@@ -130,6 +131,14 @@ export class LambdaManager {
|
|
|
130
131
|
},
|
|
131
132
|
})
|
|
132
133
|
|
|
134
|
+
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
135
|
+
lambdaFunction.addEventSource(
|
|
136
|
+
new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
137
|
+
reportBatchItemFailures: true,
|
|
138
|
+
})
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
133
142
|
if (props.lambdaAliases && props.lambdaAliases.length > 0) {
|
|
134
143
|
props.lambdaAliases.forEach(alias => {
|
|
135
144
|
const aliasId = alias.id ?? `${id}-${alias.aliasName}`
|
|
@@ -271,6 +280,14 @@ export class LambdaManager {
|
|
|
271
280
|
},
|
|
272
281
|
})
|
|
273
282
|
|
|
283
|
+
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
284
|
+
lambdaFunction.addEventSource(
|
|
285
|
+
new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
286
|
+
reportBatchItemFailures: true,
|
|
287
|
+
})
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
|
|
274
291
|
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
|
|
275
292
|
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
|
|
276
293
|
|
|
@@ -72,6 +72,7 @@ export interface SiteWithEcsBackendProps extends CommonStackProps {
|
|
|
72
72
|
siteCacheInvalidationDockerFilePath?: string
|
|
73
73
|
siteHealthCheck: HealthCheck
|
|
74
74
|
siteCertificate: AcmProps
|
|
75
|
+
siteRegionalCertificate: AcmProps
|
|
75
76
|
siteCluster: EcsClusterProps
|
|
76
77
|
siteDistribution: DistributionProps
|
|
77
78
|
siteCloudfrontFunctionProps?: CloudfrontFunctionProps
|
|
@@ -905,4 +906,5 @@ export interface QueueProps extends sqs.QueueProps {
|
|
|
905
906
|
deliveryDelayInSecs?: number
|
|
906
907
|
retentionInDays?: number
|
|
907
908
|
tags?: TagProps[]
|
|
909
|
+
retriesEnabled?: boolean
|
|
908
910
|
}
|