@gradientedge/cdk-utils 8.91.0 → 8.92.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/.eslintrc.json +40 -0
- package/app/api-destined-function/src/lib/lambda.ts +6 -6
- package/dist/app/api-destined-function/src/lib/lambda.d.ts +6 -6
- package/dist/app/api-destined-function/src/lib/lambda.js +6 -6
- package/dist/lib/lambda.d.ts +6 -6
- package/dist/lib/lambda.js +6 -6
- package/dist/lib/lambda.js.map +1 -1
- package/dist/src/lib/common/construct.d.ts +4 -7
- package/dist/src/lib/common/construct.js +4 -7
- package/dist/src/lib/common/stack.d.ts +9 -13
- package/dist/src/lib/common/stack.js +9 -13
- package/dist/src/lib/common/types.d.ts +0 -2
- package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/api.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/event.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +0 -27
- package/dist/src/lib/construct/api-to-eventbridge-target/main.js +41 -68
- package/dist/src/lib/construct/api-to-eventbridge-target/types.d.ts +13 -25
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +0 -37
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +44 -81
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/types.d.ts +1 -5
- package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +0 -3
- package/dist/src/lib/construct/api-to-lambda-target/api.js +0 -3
- package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +0 -14
- package/dist/src/lib/construct/api-to-lambda-target/main.js +7 -21
- package/dist/src/lib/construct/api-to-lambda-target/types.d.ts +7 -13
- package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +0 -18
- package/dist/src/lib/construct/graphql-api-lambda/main.js +1 -19
- package/dist/src/lib/construct/graphql-api-lambda/types.d.ts +4 -8
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +0 -11
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +1 -12
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/types.d.ts +1 -3
- package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +0 -12
- package/dist/src/lib/construct/lambda-with-iam-access/main.js +2 -14
- package/dist/src/lib/construct/rest-api-lambda/main.d.ts +0 -18
- package/dist/src/lib/construct/rest-api-lambda/main.js +1 -19
- package/dist/src/lib/construct/rest-api-lambda/types.d.ts +6 -10
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +0 -11
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +3 -14
- package/dist/src/lib/construct/rest-api-lambda-with-cache/types.d.ts +1 -3
- package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +0 -25
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +32 -52
- package/dist/src/lib/construct/site-with-ecs-backend/types.d.ts +10 -11
- package/dist/src/lib/construct/static-asset-deployment/main.d.ts +0 -8
- package/dist/src/lib/construct/static-asset-deployment/main.js +0 -8
- package/dist/src/lib/construct/static-asset-deployment/types.d.ts +1 -1
- package/dist/src/lib/construct/static-site/main.d.ts +0 -17
- package/dist/src/lib/construct/static-site/main.js +1 -18
- package/dist/src/lib/construct/static-site/types.d.ts +9 -11
- package/dist/src/lib/services/aws/api-gateway/main.d.ts +21 -25
- package/dist/src/lib/services/aws/api-gateway/main.js +42 -46
- package/dist/src/lib/services/aws/api-gateway/types.d.ts +0 -2
- package/dist/src/lib/services/aws/appconfig/constants.d.ts +0 -6
- package/dist/src/lib/services/aws/appconfig/constants.js +26 -32
- package/dist/src/lib/services/aws/appconfig/main.d.ts +16 -19
- package/dist/src/lib/services/aws/appconfig/main.js +19 -22
- package/dist/src/lib/services/aws/appconfig/types.d.ts +1 -3
- package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -10
- package/dist/src/lib/services/aws/certificate-manager/main.js +5 -10
- package/dist/src/lib/services/aws/certificate-manager/types.d.ts +3 -5
- package/dist/src/lib/services/aws/cloudfront/main.d.ts +41 -47
- package/dist/src/lib/services/aws/cloudfront/main.js +56 -62
- package/dist/src/lib/services/aws/cloudfront/types.d.ts +1 -7
- package/dist/src/lib/services/aws/cloudtrail/main.d.ts +8 -12
- package/dist/src/lib/services/aws/cloudtrail/main.js +8 -12
- package/dist/src/lib/services/aws/cloudtrail/types.d.ts +0 -2
- package/dist/src/lib/services/aws/cloudwatch/logs.d.ts +11 -15
- package/dist/src/lib/services/aws/cloudwatch/logs.js +15 -19
- package/dist/src/lib/services/aws/cloudwatch/main.d.ts +80 -84
- package/dist/src/lib/services/aws/cloudwatch/main.js +116 -122
- package/dist/src/lib/services/aws/cloudwatch/types.d.ts +20 -42
- package/dist/src/lib/services/aws/codebuild/main.d.ts +0 -4
- package/dist/src/lib/services/aws/codebuild/main.js +3 -7
- package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -7
- package/dist/src/lib/services/aws/dynamodb/main.js +13 -17
- package/dist/src/lib/services/aws/dynamodb/types.d.ts +0 -2
- package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +3 -7
- package/dist/src/lib/services/aws/elastic-container-registry/main.js +3 -7
- package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +19 -23
- package/dist/src/lib/services/aws/elastic-container-service/main.js +35 -39
- package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +1 -9
- package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +9 -13
- package/dist/src/lib/services/aws/elastic-file-system/main.js +14 -18
- package/dist/src/lib/services/aws/elastic-file-system/types.d.ts +1 -5
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +5 -9
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -12
- package/dist/src/lib/services/aws/elastic-kubernetes-service/types.d.ts +1 -3
- package/dist/src/lib/services/aws/elasticache/main.d.ts +14 -18
- package/dist/src/lib/services/aws/elasticache/main.js +35 -39
- package/dist/src/lib/services/aws/elasticache/types.d.ts +0 -4
- package/dist/src/lib/services/aws/eventbridge/main.d.ts +25 -29
- package/dist/src/lib/services/aws/eventbridge/main.js +34 -38
- package/dist/src/lib/services/aws/eventbridge/target.d.ts +6 -9
- package/dist/src/lib/services/aws/eventbridge/target.js +8 -10
- package/dist/src/lib/services/aws/eventbridge/types.d.ts +2 -10
- package/dist/src/lib/services/aws/evidently/main.d.ts +15 -19
- package/dist/src/lib/services/aws/evidently/main.js +19 -23
- package/dist/src/lib/services/aws/evidently/types.d.ts +0 -10
- package/dist/src/lib/services/aws/identity-access-management/main.d.ts +66 -70
- package/dist/src/lib/services/aws/identity-access-management/main.js +97 -101
- package/dist/src/lib/services/aws/key-management-service/main.d.ts +3 -7
- package/dist/src/lib/services/aws/key-management-service/main.js +6 -10
- package/dist/src/lib/services/aws/key-management-service/types.d.ts +0 -2
- package/dist/src/lib/services/aws/lambda/main.d.ts +42 -47
- package/dist/src/lib/services/aws/lambda/main.js +64 -69
- package/dist/src/lib/services/aws/lambda/types.d.ts +6 -16
- package/dist/src/lib/services/aws/route53/main.d.ts +17 -21
- package/dist/src/lib/services/aws/route53/main.js +19 -23
- package/dist/src/lib/services/aws/route53/types.d.ts +0 -2
- package/dist/src/lib/services/aws/secrets-manager/main.d.ts +6 -19
- package/dist/src/lib/services/aws/secrets-manager/main.js +6 -25
- package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +8 -12
- package/dist/src/lib/services/aws/simple-notification-service/main.js +10 -14
- package/dist/src/lib/services/aws/simple-notification-service/types.d.ts +0 -2
- package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +11 -15
- package/dist/src/lib/services/aws/simple-queue-service/main.js +19 -23
- package/dist/src/lib/services/aws/simple-queue-service/types.d.ts +4 -6
- package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +24 -32
- package/dist/src/lib/services/aws/simple-storage-service/main.js +32 -40
- package/dist/src/lib/services/aws/simple-storage-service/types.d.ts +2 -8
- package/dist/src/lib/services/aws/step-function/main.d.ts +55 -59
- package/dist/src/lib/services/aws/step-function/main.js +91 -95
- package/dist/src/lib/services/aws/step-function/types.d.ts +0 -32
- package/dist/src/lib/services/aws/systems-manager/main.d.ts +10 -16
- package/dist/src/lib/services/aws/systems-manager/main.js +13 -19
- package/dist/src/lib/services/aws/systems-manager/types.d.ts +0 -2
- package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +9 -12
- package/dist/src/lib/services/aws/virtual-private-cloud/main.js +10 -16
- package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +6 -10
- package/dist/src/lib/services/aws/web-application-firewall/main.js +12 -16
- package/dist/src/lib/services/aws/web-application-firewall/types.d.ts +0 -4
- package/dist/src/lib/types/aws/index.d.ts +0 -2
- package/dist/src/lib/utils/aws/index.d.ts +6 -9
- package/dist/src/lib/utils/aws/index.js +7 -10
- package/dist/src/lib/utils/index.d.ts +6 -13
- package/dist/src/lib/utils/index.js +4 -12
- package/package.json +1 -1
- package/src/lib/common/construct.ts +4 -7
- package/src/lib/common/stack.ts +9 -13
- package/src/lib/common/types.ts +0 -2
- package/src/lib/construct/api-to-eventbridge-target/api.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target/event.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target/main.ts +41 -68
- package/src/lib/construct/api-to-eventbridge-target/types.ts +13 -25
- package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +44 -81
- package/src/lib/construct/api-to-eventbridge-target-with-sns/types.ts +1 -5
- package/src/lib/construct/api-to-lambda-target/api.ts +0 -3
- package/src/lib/construct/api-to-lambda-target/main.ts +7 -21
- package/src/lib/construct/api-to-lambda-target/types.ts +7 -13
- package/src/lib/construct/graphql-api-lambda/main.ts +1 -19
- package/src/lib/construct/graphql-api-lambda/types.ts +4 -8
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +1 -12
- package/src/lib/construct/graphql-api-lambda-with-cache/types.ts +1 -3
- package/src/lib/construct/lambda-with-iam-access/main.ts +2 -14
- package/src/lib/construct/rest-api-lambda/main.ts +1 -19
- package/src/lib/construct/rest-api-lambda/types.ts +6 -10
- package/src/lib/construct/rest-api-lambda-with-cache/main.ts +3 -14
- package/src/lib/construct/rest-api-lambda-with-cache/types.ts +1 -3
- package/src/lib/construct/site-with-ecs-backend/main.ts +31 -52
- package/src/lib/construct/site-with-ecs-backend/types.ts +10 -11
- package/src/lib/construct/static-asset-deployment/main.ts +0 -8
- package/src/lib/construct/static-asset-deployment/types.ts +1 -1
- package/src/lib/construct/static-site/main.ts +1 -18
- package/src/lib/construct/static-site/types.ts +9 -11
- package/src/lib/services/aws/api-gateway/main.ts +43 -47
- package/src/lib/services/aws/api-gateway/types.ts +0 -2
- package/src/lib/services/aws/appconfig/constants.ts +26 -32
- package/src/lib/services/aws/appconfig/main.ts +19 -22
- package/src/lib/services/aws/appconfig/types.ts +1 -3
- package/src/lib/services/aws/certificate-manager/main.ts +5 -10
- package/src/lib/services/aws/certificate-manager/types.ts +3 -5
- package/src/lib/services/aws/cloudfront/main.ts +56 -62
- package/src/lib/services/aws/cloudfront/types.ts +1 -7
- package/src/lib/services/aws/cloudtrail/main.ts +8 -12
- package/src/lib/services/aws/cloudtrail/types.ts +0 -2
- package/src/lib/services/aws/cloudwatch/logs.ts +15 -19
- package/src/lib/services/aws/cloudwatch/main.ts +116 -122
- package/src/lib/services/aws/cloudwatch/types.ts +20 -42
- package/src/lib/services/aws/codebuild/main.ts +3 -7
- package/src/lib/services/aws/dynamodb/main.ts +13 -17
- package/src/lib/services/aws/dynamodb/types.ts +0 -2
- package/src/lib/services/aws/elastic-container-registry/main.ts +3 -7
- package/src/lib/services/aws/elastic-container-service/main.ts +35 -39
- package/src/lib/services/aws/elastic-container-service/types.ts +1 -9
- package/src/lib/services/aws/elastic-file-system/main.ts +14 -18
- package/src/lib/services/aws/elastic-file-system/types.ts +1 -5
- package/src/lib/services/aws/elastic-kubernetes-service/main.ts +8 -12
- package/src/lib/services/aws/elastic-kubernetes-service/types.ts +1 -3
- package/src/lib/services/aws/elasticache/main.ts +35 -39
- package/src/lib/services/aws/elasticache/types.ts +0 -4
- package/src/lib/services/aws/eventbridge/main.ts +34 -38
- package/src/lib/services/aws/eventbridge/target.ts +8 -11
- package/src/lib/services/aws/eventbridge/types.ts +2 -10
- package/src/lib/services/aws/evidently/main.ts +19 -23
- package/src/lib/services/aws/evidently/types.ts +0 -10
- package/src/lib/services/aws/identity-access-management/main.ts +97 -101
- package/src/lib/services/aws/key-management-service/main.ts +6 -10
- package/src/lib/services/aws/key-management-service/types.ts +0 -2
- package/src/lib/services/aws/lambda/main.ts +64 -69
- package/src/lib/services/aws/lambda/types.ts +6 -16
- package/src/lib/services/aws/route53/main.ts +19 -23
- package/src/lib/services/aws/route53/types.ts +0 -2
- package/src/lib/services/aws/secrets-manager/main.ts +6 -28
- package/src/lib/services/aws/simple-notification-service/main.ts +10 -14
- package/src/lib/services/aws/simple-notification-service/types.ts +0 -2
- package/src/lib/services/aws/simple-queue-service/main.ts +19 -23
- package/src/lib/services/aws/simple-queue-service/types.ts +4 -6
- package/src/lib/services/aws/simple-storage-service/main.ts +32 -40
- package/src/lib/services/aws/simple-storage-service/types.ts +2 -8
- package/src/lib/services/aws/step-function/main.ts +91 -95
- package/src/lib/services/aws/step-function/types.ts +0 -32
- package/src/lib/services/aws/systems-manager/main.ts +13 -19
- package/src/lib/services/aws/systems-manager/types.ts +0 -2
- package/src/lib/services/aws/virtual-private-cloud/main.ts +10 -16
- package/src/lib/services/aws/web-application-firewall/main.ts +12 -16
- package/src/lib/services/aws/web-application-firewall/types.ts +0 -4
- package/src/lib/types/aws/index.ts +0 -2
- package/src/lib/utils/aws/index.ts +7 -10
- package/src/lib/utils/index.ts +4 -12
|
@@ -12,9 +12,6 @@ import { CloudFrontManager } from '../cloudfront'
|
|
|
12
12
|
import { SsmManager } from '../systems-manager'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @stability stable
|
|
16
|
-
* @category cdk-utils.lambda-manager
|
|
17
|
-
* @subcategory Construct
|
|
18
15
|
* @classdesc Provides operations on AWS Lambda.
|
|
19
16
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
20
17
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -28,20 +25,19 @@ import { SsmManager } from '../systems-manager'
|
|
|
28
25
|
* this.lambdaManager.createLambdaFunction('MyFunction', this, role, layers, code)
|
|
29
26
|
* }
|
|
30
27
|
* }
|
|
31
|
-
*
|
|
32
28
|
* @see [CDK Lambda Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html}
|
|
33
29
|
*/
|
|
34
30
|
export class LambdaManager {
|
|
35
31
|
/**
|
|
36
32
|
* @summary Method to create a lambda layer (nodejs)
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
33
|
+
* @param id scoped id of the resource
|
|
34
|
+
* @param scope scope in which this resource is defined
|
|
35
|
+
* @param code
|
|
40
36
|
*/
|
|
41
37
|
public createLambdaLayer(id: string, scope: CommonConstruct, code: lambda.AssetCode) {
|
|
42
38
|
const lambdaLayer = new lambda.LayerVersion(scope, `${id}`, {
|
|
43
|
-
compatibleRuntimes: [scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME],
|
|
44
39
|
code: code,
|
|
40
|
+
compatibleRuntimes: [scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME],
|
|
45
41
|
description: `${id}`,
|
|
46
42
|
layerVersionName: `${id}-${scope.props.stage}`,
|
|
47
43
|
})
|
|
@@ -53,19 +49,19 @@ export class LambdaManager {
|
|
|
53
49
|
|
|
54
50
|
/**
|
|
55
51
|
* @summary Method to create a lambda function (nodejs)
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
52
|
+
* @param id scoped id of the resource
|
|
53
|
+
* @param scope scope in which this resource is defined
|
|
54
|
+
* @param props
|
|
55
|
+
* @param role
|
|
56
|
+
* @param layers
|
|
57
|
+
* @param code
|
|
58
|
+
* @param handler
|
|
59
|
+
* @param environment
|
|
60
|
+
* @param vpc
|
|
61
|
+
* @param securityGroups
|
|
62
|
+
* @param accessPoint
|
|
63
|
+
* @param mountPath
|
|
64
|
+
* @param vpcSubnets
|
|
69
65
|
*/
|
|
70
66
|
public createLambdaFunction(
|
|
71
67
|
id: string,
|
|
@@ -96,15 +92,10 @@ export class LambdaManager {
|
|
|
96
92
|
...props,
|
|
97
93
|
...{
|
|
98
94
|
allowPublicSubnet: !!vpc,
|
|
99
|
-
|
|
100
|
-
handler: handler || 'index.lambda_handler',
|
|
101
|
-
runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
|
|
95
|
+
architecture: props.architecture ?? lambda.Architecture.ARM_64,
|
|
102
96
|
code: code,
|
|
103
97
|
deadLetterQueue: deadLetterQueue,
|
|
104
|
-
architecture: props.architecture ?? lambda.Architecture.ARM_64,
|
|
105
98
|
environment: {
|
|
106
|
-
REGION: scope.props.region,
|
|
107
|
-
STAGE: scope.props.stage,
|
|
108
99
|
LAST_MODIFIED_TS: props.excludeLastModifiedTimestamp
|
|
109
100
|
? ''
|
|
110
101
|
: scope.ssmManager.readStringParameter(
|
|
@@ -112,30 +103,35 @@ export class LambdaManager {
|
|
|
112
103
|
scope,
|
|
113
104
|
`${SsmManager.SECRETS_MODIFIED_TIMESTAMP_PARAM}-${scope.props.stage}`
|
|
114
105
|
),
|
|
106
|
+
REGION: scope.props.region,
|
|
107
|
+
STAGE: scope.props.stage,
|
|
115
108
|
...environment,
|
|
116
109
|
},
|
|
117
110
|
filesystem: accessPoint
|
|
118
111
|
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
119
112
|
: undefined,
|
|
113
|
+
functionName: functionName,
|
|
114
|
+
handler: handler || 'index.lambda_handler',
|
|
115
|
+
insightsVersion: props.insightsVersion,
|
|
120
116
|
layers: layers,
|
|
121
117
|
logRetention: scope.props.logRetention ?? props.logRetention,
|
|
122
118
|
reservedConcurrentExecutions:
|
|
123
119
|
props.reservedConcurrentExecutions ?? scope.props.defaultReservedLambdaConcurrentExecutions,
|
|
124
120
|
role: role instanceof iam.Role ? role : undefined,
|
|
121
|
+
runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
|
|
125
122
|
securityGroups: securityGroups,
|
|
126
123
|
timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(15),
|
|
127
|
-
vpc: vpc,
|
|
128
|
-
vpcSubnets: vpcSubnets,
|
|
129
124
|
tracing: scope.props.defaultTracing ?? props.tracing,
|
|
130
|
-
|
|
125
|
+
vpc,
|
|
126
|
+
vpcSubnets,
|
|
131
127
|
},
|
|
132
128
|
})
|
|
133
129
|
|
|
134
130
|
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
135
131
|
lambdaFunction.addEventSource(
|
|
136
132
|
new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
137
|
-
reportBatchItemFailures: true,
|
|
138
133
|
batchSize: props.dlq.retryBatchSize ?? 1,
|
|
134
|
+
reportBatchItemFailures: true,
|
|
139
135
|
})
|
|
140
136
|
)
|
|
141
137
|
}
|
|
@@ -170,18 +166,17 @@ export class LambdaManager {
|
|
|
170
166
|
|
|
171
167
|
/**
|
|
172
168
|
* @summary Method to provision a Lambda@Edge function
|
|
173
|
-
*
|
|
174
|
-
* @param
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
177
|
-
* @param
|
|
178
|
-
* @param
|
|
179
|
-
* @param
|
|
180
|
-
* @param
|
|
181
|
-
* @param
|
|
182
|
-
* @param
|
|
183
|
-
* @param
|
|
184
|
-
* @param {string?} mountPath
|
|
169
|
+
* @param id scoped id of the resource
|
|
170
|
+
* @param scope scope in which this resource is defined
|
|
171
|
+
* @param props lambda@edge properties
|
|
172
|
+
* @param layers
|
|
173
|
+
* @param code
|
|
174
|
+
* @param role
|
|
175
|
+
* @param environment
|
|
176
|
+
* @param vpc
|
|
177
|
+
* @param securityGroups
|
|
178
|
+
* @param accessPoint
|
|
179
|
+
* @param mountPath
|
|
185
180
|
*/
|
|
186
181
|
public createEdgeFunction(
|
|
187
182
|
id: string,
|
|
@@ -213,17 +208,17 @@ export class LambdaManager {
|
|
|
213
208
|
|
|
214
209
|
/**
|
|
215
210
|
* @summary Method to create a lambda function (nodejs) with docker image
|
|
216
|
-
* @param
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
219
|
-
* @param
|
|
220
|
-
* @param
|
|
221
|
-
* @param
|
|
222
|
-
* @param
|
|
223
|
-
* @param
|
|
224
|
-
* @param
|
|
225
|
-
* @param
|
|
226
|
-
* @param
|
|
211
|
+
* @param id scoped id of the resource
|
|
212
|
+
* @param scope scope in which this resource is defined
|
|
213
|
+
* @param props
|
|
214
|
+
* @param role
|
|
215
|
+
* @param code
|
|
216
|
+
* @param environment
|
|
217
|
+
* @param vpc
|
|
218
|
+
* @param securityGroups
|
|
219
|
+
* @param accessPoint
|
|
220
|
+
* @param mountPath
|
|
221
|
+
* @param vpcSubnets
|
|
227
222
|
*/
|
|
228
223
|
public createLambdaDockerFunction(
|
|
229
224
|
id: string,
|
|
@@ -252,14 +247,10 @@ export class LambdaManager {
|
|
|
252
247
|
...props,
|
|
253
248
|
...{
|
|
254
249
|
allowPublicSubnet: !!vpc,
|
|
255
|
-
|
|
256
|
-
runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
|
|
250
|
+
architecture: props.architecture ?? lambda.Architecture.ARM_64,
|
|
257
251
|
code: code,
|
|
258
252
|
deadLetterQueue: deadLetterQueue,
|
|
259
|
-
architecture: props.architecture ?? lambda.Architecture.ARM_64,
|
|
260
253
|
environment: {
|
|
261
|
-
REGION: scope.props.region,
|
|
262
|
-
STAGE: scope.props.stage,
|
|
263
254
|
LAST_MODIFIED_TS: props.excludeLastModifiedTimestamp
|
|
264
255
|
? ''
|
|
265
256
|
: scope.ssmManager.readStringParameter(
|
|
@@ -267,28 +258,32 @@ export class LambdaManager {
|
|
|
267
258
|
scope,
|
|
268
259
|
`${SsmManager.SECRETS_MODIFIED_TIMESTAMP_PARAM}-${scope.props.stage}`
|
|
269
260
|
),
|
|
261
|
+
REGION: scope.props.region,
|
|
262
|
+
STAGE: scope.props.stage,
|
|
270
263
|
...environment,
|
|
271
264
|
},
|
|
272
265
|
filesystem: accessPoint
|
|
273
266
|
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
274
267
|
: undefined,
|
|
268
|
+
functionName: functionName,
|
|
269
|
+
insightsVersion: props.insightsVersion,
|
|
275
270
|
logRetention: scope.props.logRetention ?? props.logRetention,
|
|
276
271
|
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
277
272
|
role: role instanceof iam.Role ? role : undefined,
|
|
273
|
+
runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
|
|
278
274
|
securityGroups: securityGroups,
|
|
279
275
|
timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
|
|
280
|
-
vpc: vpc,
|
|
281
|
-
vpcSubnets: vpcSubnets,
|
|
282
276
|
tracing: props.tracing,
|
|
283
|
-
|
|
277
|
+
vpc,
|
|
278
|
+
vpcSubnets,
|
|
284
279
|
},
|
|
285
280
|
})
|
|
286
281
|
|
|
287
282
|
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
288
283
|
lambdaFunction.addEventSource(
|
|
289
284
|
new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
290
|
-
reportBatchItemFailures: true,
|
|
291
285
|
batchSize: props.dlq.retryBatchSize ?? 1,
|
|
286
|
+
reportBatchItemFailures: true,
|
|
292
287
|
})
|
|
293
288
|
)
|
|
294
289
|
}
|
|
@@ -301,10 +296,10 @@ export class LambdaManager {
|
|
|
301
296
|
|
|
302
297
|
/**
|
|
303
298
|
* @summary Method to create a lambda function Alias
|
|
304
|
-
* @param
|
|
305
|
-
* @param
|
|
306
|
-
* @param
|
|
307
|
-
* @param
|
|
299
|
+
* @param id scoped id of the resource
|
|
300
|
+
* @param scope scope in which this resource is defined
|
|
301
|
+
* @param props
|
|
302
|
+
* @param lambdaVersion
|
|
308
303
|
*/
|
|
309
304
|
public createLambdaFunctionAlias(
|
|
310
305
|
id: string,
|
|
@@ -317,15 +312,15 @@ export class LambdaManager {
|
|
|
317
312
|
const lambdaFunctionAlias = new lambda.Alias(scope, `${id}`, {
|
|
318
313
|
...props,
|
|
319
314
|
...{
|
|
320
|
-
aliasName: props.aliasName,
|
|
321
|
-
version: lambdaVersion,
|
|
322
315
|
additionalVersions: props.additionalVersions,
|
|
316
|
+
aliasName: props.aliasName,
|
|
323
317
|
description: props.description,
|
|
324
318
|
maxEventAge: props.maxEventAge,
|
|
325
319
|
onFailure: props.onFailure,
|
|
326
320
|
onSuccess: props.onSuccess,
|
|
327
321
|
provisionedConcurrentExecutions: props.provisionedConcurrentExecutions,
|
|
328
322
|
retryAttempts: props.retryAttempts,
|
|
323
|
+
version: lambdaVersion,
|
|
329
324
|
},
|
|
330
325
|
})
|
|
331
326
|
|
|
@@ -4,31 +4,25 @@ import { EdgeFunctionProps } from 'aws-cdk-lib/aws-cloudfront/lib/experimental'
|
|
|
4
4
|
import { QueueProps } from '../simple-queue-service'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @category cdk-utils.lambda-manager
|
|
8
|
-
* @subcategory Properties
|
|
9
7
|
*/
|
|
10
8
|
export interface ProvisionedConcurrencyProps {
|
|
11
|
-
minCapacity: number
|
|
12
9
|
maxCapacity: number
|
|
10
|
+
minCapacity: number
|
|
13
11
|
utilizationTarget: number
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
|
-
* @category cdk-utils.lambda-manager
|
|
18
|
-
* @subcategory Properties
|
|
19
15
|
*/
|
|
20
16
|
export interface LambdaProps extends FunctionProps {
|
|
21
17
|
dlq?: QueueProps
|
|
22
|
-
redriveq?: QueueProps
|
|
23
|
-
timeoutInSecs?: number
|
|
24
18
|
excludeLastModifiedTimestamp?: boolean
|
|
25
|
-
tags?: TagProps[]
|
|
26
19
|
lambdaAliases?: LambdaAliasProps[]
|
|
20
|
+
redriveq?: QueueProps
|
|
21
|
+
tags?: TagProps[]
|
|
22
|
+
timeoutInSecs?: number
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
/**
|
|
30
|
-
* @category cdk-utils.lambda-manager
|
|
31
|
-
* @subcategory Properties
|
|
32
26
|
*/
|
|
33
27
|
export interface LambdaAliasProps extends AliasProps {
|
|
34
28
|
id?: string
|
|
@@ -36,21 +30,17 @@ export interface LambdaAliasProps extends AliasProps {
|
|
|
36
30
|
}
|
|
37
31
|
|
|
38
32
|
/**
|
|
39
|
-
* @category cdk-utils.lambda-manager
|
|
40
|
-
* @subcategory Properties
|
|
41
33
|
*/
|
|
42
34
|
export interface LambdaEdgeProps extends EdgeFunctionProps {
|
|
43
|
-
timeoutInSecs?: number
|
|
44
35
|
tags?: TagProps[]
|
|
36
|
+
timeoutInSecs?: number
|
|
45
37
|
}
|
|
46
38
|
|
|
47
39
|
/**
|
|
48
|
-
* @category cdk-utils.lambda-manager
|
|
49
|
-
* @subcategory Types
|
|
50
40
|
*/
|
|
51
41
|
export interface LambdaEnvironment {
|
|
52
|
-
NODE_ENV: string
|
|
53
42
|
LOG_LEVEL: string
|
|
43
|
+
NODE_ENV: string
|
|
54
44
|
REGION?: string
|
|
55
45
|
STAGE?: string
|
|
56
46
|
TZ: string
|
|
@@ -7,9 +7,6 @@ import { CommonConstruct } from '../../../common'
|
|
|
7
7
|
import { Route53Props } from './types'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @stability stable
|
|
11
|
-
* @category cdk-utils.route53-manager
|
|
12
|
-
* @subcategory Construct
|
|
13
10
|
* @classdesc Provides operations on AWS Route53.
|
|
14
11
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
15
12
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -23,15 +20,14 @@ import { Route53Props } from './types'
|
|
|
23
20
|
* this.route53Manager.createHostedZone('MyHostedZone', this)
|
|
24
21
|
* }
|
|
25
22
|
* }
|
|
26
|
-
*
|
|
27
23
|
* @see [CDK Route53 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53-readme.html}
|
|
28
24
|
*/
|
|
29
25
|
export class Route53Manager {
|
|
30
26
|
/**
|
|
31
27
|
* @summary Method to create a hosted zone
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
28
|
+
* @param id scoped id of the resource
|
|
29
|
+
* @param scope scope in which this resource is defined
|
|
30
|
+
* @param props
|
|
35
31
|
*/
|
|
36
32
|
public createHostedZone(id: string, scope: CommonConstruct, props: Route53Props) {
|
|
37
33
|
let hostedZone: route53.IHostedZone
|
|
@@ -44,8 +40,8 @@ export class Route53Manager {
|
|
|
44
40
|
})
|
|
45
41
|
} else {
|
|
46
42
|
hostedZone = new route53.HostedZone(scope, `${id}`, {
|
|
47
|
-
zoneName: scope.props.domainName,
|
|
48
43
|
comment: `Hosted zone for ${scope.props.domainName}`,
|
|
44
|
+
zoneName: scope.props.domainName,
|
|
49
45
|
})
|
|
50
46
|
}
|
|
51
47
|
|
|
@@ -57,8 +53,8 @@ export class Route53Manager {
|
|
|
57
53
|
|
|
58
54
|
/**
|
|
59
55
|
* @summary Method to create/lookup a hosted zone
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
56
|
+
* @param id scoped id of the resource
|
|
57
|
+
* @param scope scope in which this resource is defined
|
|
62
58
|
* @param useExistingHostedZone Flag to indicate whether to lookup vs create new hosted zone
|
|
63
59
|
*/
|
|
64
60
|
public withHostedZoneFromFullyQualifiedDomainName(
|
|
@@ -74,8 +70,8 @@ export class Route53Manager {
|
|
|
74
70
|
})
|
|
75
71
|
} else {
|
|
76
72
|
hostedZone = new route53.HostedZone(scope, `${id}`, {
|
|
77
|
-
zoneName: scope.fullyQualifiedDomainName,
|
|
78
73
|
comment: `Hosted zone for ${scope.fullyQualifiedDomainName}`,
|
|
74
|
+
zoneName: scope.fullyQualifiedDomainName,
|
|
79
75
|
})
|
|
80
76
|
}
|
|
81
77
|
|
|
@@ -87,11 +83,11 @@ export class Route53Manager {
|
|
|
87
83
|
|
|
88
84
|
/**
|
|
89
85
|
* @summary Method to create a-record for cloudfront target
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @param
|
|
94
|
-
* @param
|
|
86
|
+
* @param id scoped id of the resource
|
|
87
|
+
* @param scope scope in which this resource is defined
|
|
88
|
+
* @param distribution
|
|
89
|
+
* @param hostedZone
|
|
90
|
+
* @param recordName
|
|
95
91
|
* @param skipStageFromRecord
|
|
96
92
|
*/
|
|
97
93
|
public createCloudFrontTargetARecord(
|
|
@@ -121,11 +117,11 @@ export class Route53Manager {
|
|
|
121
117
|
|
|
122
118
|
/**
|
|
123
119
|
* @summary Method to create a-record for cloudfront target
|
|
124
|
-
* @param
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
120
|
+
* @param id scoped id of the resource
|
|
121
|
+
* @param scope scope in which this resource is defined
|
|
122
|
+
* @param distribution
|
|
123
|
+
* @param hostedZone
|
|
124
|
+
* @param recordName
|
|
129
125
|
*/
|
|
130
126
|
public createCloudFrontTargetARecordV2(
|
|
131
127
|
id: string,
|
|
@@ -150,8 +146,8 @@ export class Route53Manager {
|
|
|
150
146
|
|
|
151
147
|
/**
|
|
152
148
|
* @summary Method to create a-record for restApi gateway target
|
|
153
|
-
* @param
|
|
154
|
-
* @param
|
|
149
|
+
* @param id scoped id of the resource
|
|
150
|
+
* @param scope scope in which this resource is defined
|
|
155
151
|
* @param recordName
|
|
156
152
|
* @param apiDomain
|
|
157
153
|
* @param hostedZone
|
|
@@ -5,9 +5,6 @@ import * as utils from '../../../utils'
|
|
|
5
5
|
import { CommonConstruct } from '../../../common'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @stability experimental
|
|
9
|
-
* @category cdk-utils.secrets-manager
|
|
10
|
-
* @subcategory Construct
|
|
11
8
|
* @classdesc Provides operations on AWS Secrets Manager.
|
|
12
9
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
13
10
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -21,48 +18,29 @@ import { CommonConstruct } from '../../../common'
|
|
|
21
18
|
* this.secretsManager.loadSecret('MySecretName', 'eu-west-1')
|
|
22
19
|
* }
|
|
23
20
|
* }
|
|
24
|
-
*
|
|
25
21
|
* @see [CDK Secrets Manager Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager-readme.html}
|
|
26
22
|
*/
|
|
27
23
|
export class SecretsManager {
|
|
28
24
|
/**
|
|
29
25
|
*
|
|
30
|
-
* @param
|
|
26
|
+
* @param region
|
|
31
27
|
*/
|
|
32
28
|
public getAwsSecretsManager(region: string) {
|
|
33
29
|
return new SM({ region: region })
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
/**
|
|
37
|
-
* @stability experimental
|
|
38
33
|
* @summary Method to load a secret from secrets manager
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
34
|
+
* @param secretName
|
|
35
|
+
* @param region
|
|
41
36
|
*/
|
|
42
37
|
public async loadSecret(secretName: string, region: string) {
|
|
43
38
|
const secretsManager = this.getAwsSecretsManager(region)
|
|
44
39
|
const secret: any = await Promise.all([secretsManager.getSecretValue({ SecretId: secretName })])
|
|
45
|
-
|
|
46
40
|
return secret ? JSON.parse(secret[0].SecretString) : {}
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
/**
|
|
50
|
-
* @stability experimental
|
|
51
|
-
* @summary Method to load secrets from secrets manager
|
|
52
|
-
* @param {string} secretNames
|
|
53
|
-
* @param {string} region
|
|
54
|
-
*/
|
|
55
|
-
public async loadSecrets(secretNames: string, region: string) {
|
|
56
|
-
let secrets = {}
|
|
57
|
-
for (const secretName of secretNames.split(',')) {
|
|
58
|
-
secrets = { ...secrets, ...(await this.loadSecret(secretName, region)) }
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return secrets
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @stability stable
|
|
66
44
|
* @summary Method to retrieve a secret from secrets manager with a cloudformation export
|
|
67
45
|
* @param id
|
|
68
46
|
* @param scope
|
|
@@ -79,9 +57,9 @@ export class SecretsManager {
|
|
|
79
57
|
|
|
80
58
|
/**
|
|
81
59
|
* @summary Method to create a secret
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @param
|
|
60
|
+
* @param id scoped id of the resource
|
|
61
|
+
* @param scope scope in which this resource is defined
|
|
62
|
+
* @param props the secret properties
|
|
85
63
|
*/
|
|
86
64
|
public createSecret(id: string, scope: CommonConstruct, props: secretsManager.SecretProps) {
|
|
87
65
|
const secret = new secretsManager.Secret(scope, `${id}`, {
|
|
@@ -6,9 +6,6 @@ import { CommonConstruct } from '../../../common'
|
|
|
6
6
|
import { SubscriptionProps } from './types'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @stability stable
|
|
10
|
-
* @category cdk-utils.sns-manager
|
|
11
|
-
* @subcategory Construct
|
|
12
9
|
* @classdesc Provides operations on AWS Simple Notification Service.
|
|
13
10
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
14
11
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -22,16 +19,15 @@ import { SubscriptionProps } from './types'
|
|
|
22
19
|
* this.snsManager.createEmailNotificationService('MySns', 'eu-west-1', ["test@example.com"])
|
|
23
20
|
* }
|
|
24
21
|
* }
|
|
25
|
-
*
|
|
26
22
|
* @see [CDK Simple Notification Service Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sns-readme.html}
|
|
27
23
|
*/
|
|
28
24
|
export class SnsManager {
|
|
29
25
|
/**
|
|
30
26
|
* @summary Method to create an email notification service
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
27
|
+
* @param id scoped id of the resource
|
|
28
|
+
* @param scope scope in which this resource is defined
|
|
29
|
+
* @param props
|
|
30
|
+
* @param emails
|
|
35
31
|
*/
|
|
36
32
|
public createEmailNotificationService(
|
|
37
33
|
id: string,
|
|
@@ -43,8 +39,8 @@ export class SnsManager {
|
|
|
43
39
|
|
|
44
40
|
const topic = new sns.Topic(scope, id, {
|
|
45
41
|
displayName: `${props.topicName}-${scope.props.stage}`,
|
|
46
|
-
topicName: `${props.topicName}-${scope.props.stage}`,
|
|
47
42
|
fifo: props.fifo,
|
|
43
|
+
topicName: `${props.topicName}-${scope.props.stage}`,
|
|
48
44
|
})
|
|
49
45
|
|
|
50
46
|
if (emails && emails.length > 0) {
|
|
@@ -59,10 +55,10 @@ export class SnsManager {
|
|
|
59
55
|
|
|
60
56
|
/**
|
|
61
57
|
* @summary Method to create a lambda notification service
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
58
|
+
* @param id scoped id of the resource
|
|
59
|
+
* @param scope scope in which this resource is defined
|
|
60
|
+
* @param props
|
|
61
|
+
* @param lambdaFunction
|
|
66
62
|
*/
|
|
67
63
|
public createLambdaNotificationService(
|
|
68
64
|
id: string,
|
|
@@ -74,8 +70,8 @@ export class SnsManager {
|
|
|
74
70
|
|
|
75
71
|
const topic = new sns.Topic(scope, id, {
|
|
76
72
|
displayName: `${props.topicName}-${scope.props.stage}`,
|
|
77
|
-
topicName: `${props.topicName}-${scope.props.stage}`,
|
|
78
73
|
fifo: props.fifo,
|
|
74
|
+
topicName: `${props.topicName}-${scope.props.stage}`,
|
|
79
75
|
})
|
|
80
76
|
|
|
81
77
|
topic.addSubscription(new subs.LambdaSubscription(lambdaFunction))
|
|
@@ -6,9 +6,6 @@ import { QueueProps } from './types'
|
|
|
6
6
|
import { LambdaProps } from '../lambda'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @stability stable
|
|
10
|
-
* @category cdk-utils.sqs-manager
|
|
11
|
-
* @subcategory Construct
|
|
12
9
|
* @classdesc Provides operations on AWS Simple Queue Service.
|
|
13
10
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
14
11
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -22,35 +19,27 @@ import { LambdaProps } from '../lambda'
|
|
|
22
19
|
* this.sqsManager.createQueue('MySqs', this, {...})
|
|
23
20
|
* }
|
|
24
21
|
* }
|
|
25
|
-
*
|
|
26
22
|
* @see [CDK Simple Queue Service Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs-readme.html}
|
|
27
23
|
*/
|
|
28
24
|
export class SqsManager {
|
|
29
25
|
/**
|
|
30
26
|
* @summary Method to create a lambda queue service
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
27
|
+
* @param id scoped id of the resource
|
|
28
|
+
* @param scope scope in which this resource is defined
|
|
29
|
+
* @param props
|
|
30
|
+
* @param deadLetterQueue
|
|
35
31
|
*/
|
|
36
32
|
public createQueue(id: string, scope: CommonConstruct, props: QueueProps, deadLetterQueue?: sqs.IQueue) {
|
|
37
33
|
if (!props) throw `Queue props undefined for ${id}`
|
|
38
34
|
|
|
39
35
|
const queue = new sqs.Queue(scope, id, {
|
|
40
|
-
queueName: props.queueName,
|
|
41
|
-
visibilityTimeout: props.visibilityTimeoutInSecs
|
|
42
|
-
? cdk.Duration.seconds(props.visibilityTimeoutInSecs)
|
|
43
|
-
: props.visibilityTimeout,
|
|
44
|
-
receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
|
|
45
|
-
? cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs)
|
|
46
|
-
: props.receiveMessageWaitTime,
|
|
47
36
|
contentBasedDeduplication: props.contentBasedDeduplication,
|
|
48
37
|
dataKeyReuse: props.dataKeyReuseInSecs ? cdk.Duration.seconds(props.dataKeyReuseInSecs) : props.dataKeyReuse,
|
|
49
38
|
deadLetterQueue: !deadLetterQueue
|
|
50
39
|
? undefined
|
|
51
40
|
: {
|
|
52
|
-
queue: deadLetterQueue,
|
|
53
41
|
maxReceiveCount: props.maxReceiveCount ?? 5,
|
|
42
|
+
queue: deadLetterQueue,
|
|
54
43
|
},
|
|
55
44
|
deduplicationScope: props.deduplicationScope,
|
|
56
45
|
deliveryDelay: props.deliveryDelayInSecs ? cdk.Duration.seconds(props.deliveryDelayInSecs) : undefined,
|
|
@@ -59,8 +48,15 @@ export class SqsManager {
|
|
|
59
48
|
fifo: props.fifo,
|
|
60
49
|
fifoThroughputLimit: props.fifoThroughputLimit,
|
|
61
50
|
maxMessageSizeBytes: props.maxMessageSizeBytes,
|
|
51
|
+
queueName: props.queueName,
|
|
52
|
+
receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
|
|
53
|
+
? cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs)
|
|
54
|
+
: props.receiveMessageWaitTime,
|
|
62
55
|
removalPolicy: props.removalPolicy ?? cdk.RemovalPolicy.DESTROY,
|
|
63
56
|
retentionPeriod: props.retentionInDays ? cdk.Duration.days(props.retentionInDays) : cdk.Duration.days(7),
|
|
57
|
+
visibilityTimeout: props.visibilityTimeoutInSecs
|
|
58
|
+
? cdk.Duration.seconds(props.visibilityTimeoutInSecs)
|
|
59
|
+
: props.visibilityTimeout,
|
|
64
60
|
})
|
|
65
61
|
|
|
66
62
|
if (props.tags && props.tags.length > 0) {
|
|
@@ -78,9 +74,9 @@ export class SqsManager {
|
|
|
78
74
|
|
|
79
75
|
/**
|
|
80
76
|
* @summary Method to create a redrive queue for a lambda function
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
77
|
+
* @param id scoped id of the resource
|
|
78
|
+
* @param scope scope in which this resource is defined
|
|
79
|
+
* @param props the lambda properties
|
|
84
80
|
*/
|
|
85
81
|
public createRedriveQueueForLambda(id: string, scope: CommonConstruct, props: LambdaProps) {
|
|
86
82
|
return this.createQueue(`${id}`, scope, {
|
|
@@ -93,10 +89,10 @@ export class SqsManager {
|
|
|
93
89
|
|
|
94
90
|
/**
|
|
95
91
|
* @summary Method to create a dead letter queue for a lambda function
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
92
|
+
* @param id scoped id of the resource
|
|
93
|
+
* @param scope scope in which this resource is defined
|
|
94
|
+
* @param props the lambda properties
|
|
95
|
+
* @param deadLetterQueue
|
|
100
96
|
*/
|
|
101
97
|
public createDeadLetterQueueForLambda(
|
|
102
98
|
id: string,
|