@gradientedge/cdk-utils 8.74.0 → 8.75.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/graphql-api-lambda/main.d.ts +2 -1
- package/dist/src/lib/construct/graphql-api-lambda/main.js +2 -1
- package/dist/src/lib/construct/rest-api-lambda/main.d.ts +11 -7
- package/dist/src/lib/construct/rest-api-lambda/main.js +12 -5
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +2 -2
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +11 -1
- package/dist/src/lib/manager/aws/api-manager.js +1 -0
- package/dist/src/lib/types/aws/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/lib/construct/graphql-api-lambda/main.ts +2 -1
- package/src/lib/construct/rest-api-lambda/main.ts +17 -7
- package/src/lib/construct/rest-api-lambda-with-cache/main.ts +15 -3
- package/src/lib/manager/aws/api-manager.ts +1 -0
- package/src/lib/types/aws/index.ts +1 -1
|
@@ -8,7 +8,8 @@ import { Construct } from 'constructs';
|
|
|
8
8
|
import { CommonConstruct } from '../../common';
|
|
9
9
|
import { GraphQlApiLambdaEnvironment, GraphQlApiLambdaProps } from '../../types';
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
11
|
+
* @deprecated Use RestApiLambda instead. This will be removed in a future release.
|
|
12
|
+
*
|
|
12
13
|
* @category cdk-utils.graphql-api-lambda
|
|
13
14
|
* @subcategory construct
|
|
14
15
|
* @classdesc Provides a construct to create and deploy a Graphql API as Lambda
|
|
@@ -28,7 +28,8 @@ const apig = __importStar(require("aws-cdk-lib/aws-apigateway"));
|
|
|
28
28
|
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
29
29
|
const common_1 = require("../../common");
|
|
30
30
|
/**
|
|
31
|
-
* @
|
|
31
|
+
* @deprecated Use RestApiLambda instead. This will be removed in a future release.
|
|
32
|
+
*
|
|
32
33
|
* @category cdk-utils.graphql-api-lambda
|
|
33
34
|
* @subcategory construct
|
|
34
35
|
* @classdesc Provides a construct to create and deploy a Graphql API as Lambda
|
|
@@ -8,8 +8,6 @@ import { Construct } from 'constructs';
|
|
|
8
8
|
import { CommonConstruct } from '../../common';
|
|
9
9
|
import { RestApiLambdaEnvironment, RestApiLambdaProps } from '../../types';
|
|
10
10
|
/**
|
|
11
|
-
* @deprecated Use RestApiLambda instead. This will be removed in a future release.
|
|
12
|
-
*
|
|
13
11
|
* @category cdk-utils.rest-api-lambda
|
|
14
12
|
* @subcategory construct
|
|
15
13
|
* @classdesc Provides a construct to create and deploy a RestApi as Lambda
|
|
@@ -30,7 +28,7 @@ import { RestApiLambdaEnvironment, RestApiLambdaProps } from '../../types';
|
|
|
30
28
|
* }
|
|
31
29
|
* @mixin
|
|
32
30
|
*/
|
|
33
|
-
export declare class RestApiLambda extends CommonConstruct {
|
|
31
|
+
export declare abstract class RestApiLambda extends CommonConstruct {
|
|
34
32
|
props: RestApiLambdaProps;
|
|
35
33
|
id: string;
|
|
36
34
|
applicationSecrets: secretsmanager.ISecret[];
|
|
@@ -44,7 +42,7 @@ export declare class RestApiLambda extends CommonConstruct {
|
|
|
44
42
|
restApiCertificate: acm.ICertificate;
|
|
45
43
|
restApiDomain: apig.DomainName;
|
|
46
44
|
restApiBasePathMappings: apig.BasePathMapping[];
|
|
47
|
-
constructor(parent: Construct, id: string, props: RestApiLambdaProps);
|
|
45
|
+
protected constructor(parent: Construct, id: string, props: RestApiLambdaProps);
|
|
48
46
|
/**
|
|
49
47
|
* @summary Initialise and provision resources
|
|
50
48
|
* @protected
|
|
@@ -96,19 +94,25 @@ export declare class RestApiLambda extends CommonConstruct {
|
|
|
96
94
|
* @protected
|
|
97
95
|
*/
|
|
98
96
|
protected createRestApi(): void;
|
|
97
|
+
protected abstract createRestApiResources(): void;
|
|
99
98
|
/**
|
|
100
|
-
* @summary Method to create custom restApiLambda domain for RestApi
|
|
99
|
+
* @summary Method to create custom restApiLambda domain for RestApi
|
|
101
100
|
* @protected
|
|
102
101
|
*/
|
|
103
102
|
protected createApiDomain(): void;
|
|
104
103
|
/**
|
|
105
|
-
* @summary Method to create base path mappings for RestApi
|
|
104
|
+
* @summary Method to create base path mappings for RestApi
|
|
106
105
|
* @protected
|
|
107
106
|
*/
|
|
108
107
|
protected createApiBasePathMapping(): void;
|
|
109
108
|
/**
|
|
110
|
-
* @summary Method to create route53 records for RestApi
|
|
109
|
+
* @summary Method to create route53 records for RestApi
|
|
111
110
|
* @protected
|
|
112
111
|
*/
|
|
113
112
|
protected createApiRouteAssets(): void;
|
|
113
|
+
/**
|
|
114
|
+
* @summary Method to deploy the changes to the RestApi
|
|
115
|
+
* @protected
|
|
116
|
+
*/
|
|
117
|
+
protected createRestApiDeployment(): void;
|
|
114
118
|
}
|
|
@@ -28,8 +28,6 @@ const apig = __importStar(require("aws-cdk-lib/aws-apigateway"));
|
|
|
28
28
|
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
29
29
|
const common_1 = require("../../common");
|
|
30
30
|
/**
|
|
31
|
-
* @deprecated Use RestApiLambda instead. This will be removed in a future release.
|
|
32
|
-
*
|
|
33
31
|
* @category cdk-utils.rest-api-lambda
|
|
34
32
|
* @subcategory construct
|
|
35
33
|
* @classdesc Provides a construct to create and deploy a RestApi as Lambda
|
|
@@ -85,9 +83,11 @@ class RestApiLambda extends common_1.CommonConstruct {
|
|
|
85
83
|
this.createLambdaLayers();
|
|
86
84
|
this.createLambdaFunction();
|
|
87
85
|
this.createRestApi();
|
|
86
|
+
this.createRestApiResources();
|
|
88
87
|
this.createApiDomain();
|
|
89
88
|
this.createApiBasePathMapping();
|
|
90
89
|
this.createApiRouteAssets();
|
|
90
|
+
this.createRestApiDeployment();
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* @summary Method to resolve secrets from SecretsManager
|
|
@@ -171,7 +171,7 @@ class RestApiLambda extends common_1.CommonConstruct {
|
|
|
171
171
|
this.restApi = this.apiManager.createLambdaRestApi(`${this.id}-lambda-rest-api`, this, this.props.restApi, this.restApiLambdaFunction);
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
|
-
* @summary Method to create custom restApiLambda domain for RestApi
|
|
174
|
+
* @summary Method to create custom restApiLambda domain for RestApi
|
|
175
175
|
* @protected
|
|
176
176
|
*/
|
|
177
177
|
createApiDomain() {
|
|
@@ -180,7 +180,7 @@ class RestApiLambda extends common_1.CommonConstruct {
|
|
|
180
180
|
: `${this.props.apiSubDomain}-${this.props.stage}.${this.fullyQualifiedDomainName}`, this.restApiCertificate);
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
* @summary Method to create base path mappings for RestApi
|
|
183
|
+
* @summary Method to create base path mappings for RestApi
|
|
184
184
|
* @protected
|
|
185
185
|
*/
|
|
186
186
|
createApiBasePathMapping() {
|
|
@@ -204,11 +204,18 @@ class RestApiLambda extends common_1.CommonConstruct {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
207
|
-
* @summary Method to create route53 records for RestApi
|
|
207
|
+
* @summary Method to create route53 records for RestApi
|
|
208
208
|
* @protected
|
|
209
209
|
*/
|
|
210
210
|
createApiRouteAssets() {
|
|
211
211
|
this.route53Manager.createApiGatewayARecord(`${this.id}-custom-domain-a-record`, this, this.props.apiSubDomain, this.restApiDomain, this.restApiHostedZone, this.props.skipStageForARecords);
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* @summary Method to deploy the changes to the RestApi
|
|
215
|
+
* @protected
|
|
216
|
+
*/
|
|
217
|
+
createRestApiDeployment() {
|
|
218
|
+
this.apiManager.createApiDeployment(`${this.id}-deployment`, this, this.restApi);
|
|
219
|
+
}
|
|
213
220
|
}
|
|
214
221
|
exports.RestApiLambda = RestApiLambda;
|
|
@@ -25,14 +25,14 @@ import { RestApiLambdaWithCacheProps } from '../../types';
|
|
|
25
25
|
* }
|
|
26
26
|
* @mixin
|
|
27
27
|
*/
|
|
28
|
-
export declare class RestApiLambdaWithCache extends RestApiLambda {
|
|
28
|
+
export declare abstract class RestApiLambdaWithCache extends RestApiLambda {
|
|
29
29
|
props: RestApiLambdaWithCacheProps;
|
|
30
30
|
id: string;
|
|
31
31
|
restApivpc: ec2.IVpc;
|
|
32
32
|
restApiCache: elasticache.CfnReplicationGroup;
|
|
33
33
|
restApiSecurityGroup: ec2.ISecurityGroup;
|
|
34
34
|
restApiSecurityGroupExportName: string;
|
|
35
|
-
constructor(parent: Construct, id: string, props: RestApiLambdaWithCacheProps);
|
|
35
|
+
protected constructor(parent: Construct, id: string, props: RestApiLambdaWithCacheProps);
|
|
36
36
|
protected initResources(): void;
|
|
37
37
|
/**
|
|
38
38
|
* Create VPC
|
|
@@ -105,7 +105,17 @@ class RestApiLambdaWithCache extends __1.RestApiLambda {
|
|
|
105
105
|
* @protected
|
|
106
106
|
*/
|
|
107
107
|
createElastiCache() {
|
|
108
|
-
this.restApiCache = this.elasticacheManager.createReplicatedElastiCache(`${this.id}-elasticache`, this, this.props.
|
|
108
|
+
this.restApiCache = this.elasticacheManager.createReplicatedElastiCache(`${this.id}-elasticache`, this, this.props.restApiCache, this.restApivpc.privateSubnets.map(subnet => subnet.subnetId), [this.restApiSecurityGroup.securityGroupId]);
|
|
109
|
+
this.ssmManager.writeStringToParameters(`${this.id}-elasticache-endpoint-address`, this, {
|
|
110
|
+
parameterName: `${this.id}-elasticache-endpoint-address`,
|
|
111
|
+
description: `Elasticache address to use by applications`,
|
|
112
|
+
stringValue: this.restApiCache.attrConfigurationEndPointAddress,
|
|
113
|
+
});
|
|
114
|
+
this.ssmManager.writeStringToParameters(`${this.id}-elasticache-endpoint-port`, this, {
|
|
115
|
+
parameterName: `${this.id}-elasticache-endpoint-port`,
|
|
116
|
+
description: `Elasticache port to use by applications`,
|
|
117
|
+
stringValue: this.restApiCache.attrConfigurationEndPointPort,
|
|
118
|
+
});
|
|
109
119
|
}
|
|
110
120
|
/**
|
|
111
121
|
* Create Lambda Role
|
|
@@ -79,6 +79,7 @@ class ApiManager {
|
|
|
79
79
|
loggingLevel: props.deployOptions?.loggingLevel,
|
|
80
80
|
dataTraceEnabled: props.deployOptions?.dataTraceEnabled,
|
|
81
81
|
cachingEnabled: props.deployOptions?.cachingEnabled,
|
|
82
|
+
metricsEnabled: props.deployOptions?.metricsEnabled,
|
|
82
83
|
},
|
|
83
84
|
retainDeployments: props.retainDeployments,
|
|
84
85
|
parameters: props.parameters,
|
|
@@ -316,7 +316,7 @@ export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
|
|
|
316
316
|
*/
|
|
317
317
|
export interface RestApiLambdaWithCacheProps extends RestApiLambdaProps {
|
|
318
318
|
restApiVpc: ec2.VpcProps;
|
|
319
|
-
|
|
319
|
+
restApiCache: ReplicatedElastiCacheProps;
|
|
320
320
|
securityGroupExportName: string;
|
|
321
321
|
useExistingVpc: boolean;
|
|
322
322
|
vpcName?: string;
|
package/package.json
CHANGED
|
@@ -9,7 +9,8 @@ import { CommonConstruct } from '../../common'
|
|
|
9
9
|
import { GraphQlApiLambdaEnvironment, GraphQlApiLambdaProps } from '../../types'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @
|
|
12
|
+
* @deprecated Use RestApiLambda instead. This will be removed in a future release.
|
|
13
|
+
*
|
|
13
14
|
* @category cdk-utils.graphql-api-lambda
|
|
14
15
|
* @subcategory construct
|
|
15
16
|
* @classdesc Provides a construct to create and deploy a Graphql API as Lambda
|
|
@@ -9,8 +9,6 @@ import { CommonConstruct } from '../../common'
|
|
|
9
9
|
import { RestApiLambdaEnvironment, RestApiLambdaProps } from '../../types'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @deprecated Use RestApiLambda instead. This will be removed in a future release.
|
|
13
|
-
*
|
|
14
12
|
* @category cdk-utils.rest-api-lambda
|
|
15
13
|
* @subcategory construct
|
|
16
14
|
* @classdesc Provides a construct to create and deploy a RestApi as Lambda
|
|
@@ -31,7 +29,7 @@ import { RestApiLambdaEnvironment, RestApiLambdaProps } from '../../types'
|
|
|
31
29
|
* }
|
|
32
30
|
* @mixin
|
|
33
31
|
*/
|
|
34
|
-
export class RestApiLambda extends CommonConstruct {
|
|
32
|
+
export abstract class RestApiLambda extends CommonConstruct {
|
|
35
33
|
/* restApiLambda props */
|
|
36
34
|
props: RestApiLambdaProps
|
|
37
35
|
id: string
|
|
@@ -49,7 +47,7 @@ export class RestApiLambda extends CommonConstruct {
|
|
|
49
47
|
restApiDomain: apig.DomainName
|
|
50
48
|
restApiBasePathMappings: apig.BasePathMapping[] = []
|
|
51
49
|
|
|
52
|
-
constructor(parent: Construct, id: string, props: RestApiLambdaProps) {
|
|
50
|
+
protected constructor(parent: Construct, id: string, props: RestApiLambdaProps) {
|
|
53
51
|
super(parent, id, props)
|
|
54
52
|
|
|
55
53
|
this.props = props
|
|
@@ -70,9 +68,11 @@ export class RestApiLambda extends CommonConstruct {
|
|
|
70
68
|
this.createLambdaLayers()
|
|
71
69
|
this.createLambdaFunction()
|
|
72
70
|
this.createRestApi()
|
|
71
|
+
this.createRestApiResources()
|
|
73
72
|
this.createApiDomain()
|
|
74
73
|
this.createApiBasePathMapping()
|
|
75
74
|
this.createApiRouteAssets()
|
|
75
|
+
this.createRestApiDeployment()
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
@@ -201,8 +201,10 @@ export class RestApiLambda extends CommonConstruct {
|
|
|
201
201
|
)
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
protected abstract createRestApiResources(): void
|
|
205
|
+
|
|
204
206
|
/**
|
|
205
|
-
* @summary Method to create custom restApiLambda domain for RestApi
|
|
207
|
+
* @summary Method to create custom restApiLambda domain for RestApi
|
|
206
208
|
* @protected
|
|
207
209
|
*/
|
|
208
210
|
protected createApiDomain() {
|
|
@@ -217,7 +219,7 @@ export class RestApiLambda extends CommonConstruct {
|
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
/**
|
|
220
|
-
* @summary Method to create base path mappings for RestApi
|
|
222
|
+
* @summary Method to create base path mappings for RestApi
|
|
221
223
|
* @protected
|
|
222
224
|
*/
|
|
223
225
|
protected createApiBasePathMapping() {
|
|
@@ -245,7 +247,7 @@ export class RestApiLambda extends CommonConstruct {
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
/**
|
|
248
|
-
* @summary Method to create route53 records for RestApi
|
|
250
|
+
* @summary Method to create route53 records for RestApi
|
|
249
251
|
* @protected
|
|
250
252
|
*/
|
|
251
253
|
protected createApiRouteAssets() {
|
|
@@ -258,4 +260,12 @@ export class RestApiLambda extends CommonConstruct {
|
|
|
258
260
|
this.props.skipStageForARecords
|
|
259
261
|
)
|
|
260
262
|
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @summary Method to deploy the changes to the RestApi
|
|
266
|
+
* @protected
|
|
267
|
+
*/
|
|
268
|
+
protected createRestApiDeployment() {
|
|
269
|
+
this.apiManager.createApiDeployment(`${this.id}-deployment`, this, this.restApi)
|
|
270
|
+
}
|
|
261
271
|
}
|
|
@@ -29,7 +29,7 @@ import * as utils from '../../utils'
|
|
|
29
29
|
* }
|
|
30
30
|
* @mixin
|
|
31
31
|
*/
|
|
32
|
-
export class RestApiLambdaWithCache extends RestApiLambda {
|
|
32
|
+
export abstract class RestApiLambdaWithCache extends RestApiLambda {
|
|
33
33
|
/* restApiLambdaWithCache props */
|
|
34
34
|
props: RestApiLambdaWithCacheProps
|
|
35
35
|
id: string
|
|
@@ -40,7 +40,7 @@ export class RestApiLambdaWithCache extends RestApiLambda {
|
|
|
40
40
|
restApiSecurityGroup: ec2.ISecurityGroup
|
|
41
41
|
restApiSecurityGroupExportName: string
|
|
42
42
|
|
|
43
|
-
constructor(parent: Construct, id: string, props: RestApiLambdaWithCacheProps) {
|
|
43
|
+
protected constructor(parent: Construct, id: string, props: RestApiLambdaWithCacheProps) {
|
|
44
44
|
super(parent, id, props)
|
|
45
45
|
|
|
46
46
|
this.props = props
|
|
@@ -97,10 +97,22 @@ export class RestApiLambdaWithCache extends RestApiLambda {
|
|
|
97
97
|
this.restApiCache = this.elasticacheManager.createReplicatedElastiCache(
|
|
98
98
|
`${this.id}-elasticache`,
|
|
99
99
|
this,
|
|
100
|
-
this.props.
|
|
100
|
+
this.props.restApiCache,
|
|
101
101
|
this.restApivpc.privateSubnets.map(subnet => subnet.subnetId),
|
|
102
102
|
[this.restApiSecurityGroup.securityGroupId]
|
|
103
103
|
)
|
|
104
|
+
|
|
105
|
+
this.ssmManager.writeStringToParameters(`${this.id}-elasticache-endpoint-address`, this, {
|
|
106
|
+
parameterName: `${this.id}-elasticache-endpoint-address`,
|
|
107
|
+
description: `Elasticache address to use by applications`,
|
|
108
|
+
stringValue: this.restApiCache.attrConfigurationEndPointAddress,
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
this.ssmManager.writeStringToParameters(`${this.id}-elasticache-endpoint-port`, this, {
|
|
112
|
+
parameterName: `${this.id}-elasticache-endpoint-port`,
|
|
113
|
+
description: `Elasticache port to use by applications`,
|
|
114
|
+
stringValue: this.restApiCache.attrConfigurationEndPointPort,
|
|
115
|
+
})
|
|
104
116
|
}
|
|
105
117
|
|
|
106
118
|
/**
|
|
@@ -62,6 +62,7 @@ export class ApiManager {
|
|
|
62
62
|
loggingLevel: props.deployOptions?.loggingLevel,
|
|
63
63
|
dataTraceEnabled: props.deployOptions?.dataTraceEnabled,
|
|
64
64
|
cachingEnabled: props.deployOptions?.cachingEnabled,
|
|
65
|
+
metricsEnabled: props.deployOptions?.metricsEnabled,
|
|
65
66
|
},
|
|
66
67
|
retainDeployments: props.retainDeployments,
|
|
67
68
|
parameters: props.parameters,
|
|
@@ -340,7 +340,7 @@ export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
|
|
|
340
340
|
*/
|
|
341
341
|
export interface RestApiLambdaWithCacheProps extends RestApiLambdaProps {
|
|
342
342
|
restApiVpc: ec2.VpcProps
|
|
343
|
-
|
|
343
|
+
restApiCache: ReplicatedElastiCacheProps
|
|
344
344
|
securityGroupExportName: string
|
|
345
345
|
useExistingVpc: boolean
|
|
346
346
|
vpcName?: string
|