@gradientedge/cdk-utils 4.7.1 → 4.9.2
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/app/api-destined-function/layers/nodejs/node_modules/.yarn-integrity +1 -1
- package/dist/src/lib/construct/graphql-api-lambda/main.js +7 -0
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +0 -1
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +2 -3
- package/dist/src/lib/manager/aws/api-manager.d.ts +21 -0
- package/dist/src/lib/manager/aws/api-manager.js +52 -1
- package/dist/src/lib/types/aws/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/lib/construct/graphql-api-lambda/main.ts +8 -0
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +2 -3
- package/src/lib/manager/aws/api-manager.ts +67 -1
- package/src/lib/types/aws/index.ts +2 -1
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"glob@^7.1.3": "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023",
|
|
24
24
|
"inflight@^1.0.4": "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9",
|
|
25
25
|
"inherits@2": "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c",
|
|
26
|
-
"minimatch@^3.0.4": "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.
|
|
26
|
+
"minimatch@^3.0.4": "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b",
|
|
27
27
|
"mkdirp@^1.0.4": "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e",
|
|
28
28
|
"once@^1.3.0": "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1",
|
|
29
29
|
"path-is-absolute@^1.0.0": "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f",
|
|
@@ -188,7 +188,14 @@ class GraphQLApiLambda extends common_1.CommonConstruct {
|
|
|
188
188
|
stage: this.graphQLApi.deploymentStage,
|
|
189
189
|
}));
|
|
190
190
|
});
|
|
191
|
+
return;
|
|
191
192
|
}
|
|
193
|
+
// add default mapping if apiRootPaths not set
|
|
194
|
+
new apig.BasePathMapping(this, `${this.id}-base-bath-mapping`, {
|
|
195
|
+
domainName: this.graphQLApiDomain,
|
|
196
|
+
restApi: this.graphQLApi,
|
|
197
|
+
stage: this.graphQLApi.deploymentStage,
|
|
198
|
+
});
|
|
192
199
|
}
|
|
193
200
|
/**
|
|
194
201
|
* @summary Method to create route53 records for GraphQL API
|
|
@@ -30,7 +30,6 @@ export declare class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
30
30
|
graphQLVpc: ec2.IVpc;
|
|
31
31
|
graphQLElastiCache: elasticache.CfnCacheCluster;
|
|
32
32
|
graphQLSecurityGroup: ec2.ISecurityGroup;
|
|
33
|
-
securityGroupStackName: string;
|
|
34
33
|
securityGroupExportName: string;
|
|
35
34
|
vpcExportName: string;
|
|
36
35
|
constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps);
|
|
@@ -54,7 +54,6 @@ class GraphQLApiLambdaWithCache extends __1.GraphQLApiLambda {
|
|
|
54
54
|
graphQLVpc;
|
|
55
55
|
graphQLElastiCache;
|
|
56
56
|
graphQLSecurityGroup;
|
|
57
|
-
securityGroupStackName;
|
|
58
57
|
securityGroupExportName;
|
|
59
58
|
vpcExportName;
|
|
60
59
|
constructor(parent, id, props) {
|
|
@@ -73,8 +72,8 @@ class GraphQLApiLambdaWithCache extends __1.GraphQLApiLambda {
|
|
|
73
72
|
* @protected
|
|
74
73
|
*/
|
|
75
74
|
setVpc() {
|
|
76
|
-
if (this.props.
|
|
77
|
-
this.graphQLVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.
|
|
75
|
+
if (this.props.useExistingVpc) {
|
|
76
|
+
this.graphQLVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.vpcName);
|
|
78
77
|
}
|
|
79
78
|
else {
|
|
80
79
|
this.graphQLVpc = this.vpcManager.createCommonVpc(this, this.props.graphQLVpc, this.props.graphQLVpc.vpcName);
|
|
@@ -40,4 +40,25 @@ export declare class ApiManager {
|
|
|
40
40
|
* @param certificate the certificate used for custom restApi domain
|
|
41
41
|
*/
|
|
42
42
|
createApiDomain(id: string, scope: common.CommonConstruct, domainName: string, certificate: acm.ICertificate): apig.DomainName;
|
|
43
|
+
/**
|
|
44
|
+
* @summary Method to create an API gateway resource
|
|
45
|
+
* @param {string} id
|
|
46
|
+
* @param {common.CommonConstruct} scope
|
|
47
|
+
* @param {apig.IResource} parent
|
|
48
|
+
* @param {string} path
|
|
49
|
+
* @param {apig.Integration} integration
|
|
50
|
+
* @param {boolean} addProxy
|
|
51
|
+
* @param {apig.IAuthorizer} authorizer
|
|
52
|
+
* @param {string[]?} allowedOrigins
|
|
53
|
+
* @param {string[]?} allowedMethods
|
|
54
|
+
* @param {string[]?} allowedHeaders
|
|
55
|
+
*/
|
|
56
|
+
createApiResource(id: string, scope: common.CommonConstruct, parent: apig.IResource, path: string, integration: apig.Integration, addProxy: boolean, authorizer?: apig.IAuthorizer, allowedOrigins?: string[], allowedMethods?: string[], allowedHeaders?: string[]): apig.Resource;
|
|
57
|
+
/**
|
|
58
|
+
* @summary Method to create an api deployment
|
|
59
|
+
* @param {string} id
|
|
60
|
+
* @param {common.CommonConstruct} scope
|
|
61
|
+
* @param {apig.IRestApi} restApi
|
|
62
|
+
*/
|
|
63
|
+
createApiDeployment(id: string, scope: common.CommonConstruct, restApi: apig.IRestApi): void;
|
|
43
64
|
}
|
|
@@ -84,7 +84,7 @@ class ApiManager {
|
|
|
84
84
|
restApiName: `${props.restApiName}-${scope.props.stage}`,
|
|
85
85
|
handler: lambdaFunction,
|
|
86
86
|
defaultCorsPreflightOptions: props.defaultCorsPreflightOptions,
|
|
87
|
-
proxy: props.proxy
|
|
87
|
+
proxy: props.proxy ?? true,
|
|
88
88
|
});
|
|
89
89
|
utils.createCfnOutput(`${id}-restApiId`, scope, api.restApiId);
|
|
90
90
|
utils.createCfnOutput(`${id}-restApiName`, scope, api.restApiName);
|
|
@@ -107,5 +107,56 @@ class ApiManager {
|
|
|
107
107
|
utils.createCfnOutput(`${id}-customDomainName`, scope, apiDomain.domainName);
|
|
108
108
|
return apiDomain;
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* @summary Method to create an API gateway resource
|
|
112
|
+
* @param {string} id
|
|
113
|
+
* @param {common.CommonConstruct} scope
|
|
114
|
+
* @param {apig.IResource} parent
|
|
115
|
+
* @param {string} path
|
|
116
|
+
* @param {apig.Integration} integration
|
|
117
|
+
* @param {boolean} addProxy
|
|
118
|
+
* @param {apig.IAuthorizer} authorizer
|
|
119
|
+
* @param {string[]?} allowedOrigins
|
|
120
|
+
* @param {string[]?} allowedMethods
|
|
121
|
+
* @param {string[]?} allowedHeaders
|
|
122
|
+
*/
|
|
123
|
+
createApiResource(id, scope, parent, path, integration, addProxy, authorizer, allowedOrigins, allowedMethods, allowedHeaders) {
|
|
124
|
+
const methods = allowedMethods ?? apig.Cors.ALL_METHODS;
|
|
125
|
+
const resource = parent.addResource(path, {
|
|
126
|
+
defaultCorsPreflightOptions: {
|
|
127
|
+
allowOrigins: allowedOrigins ?? apig.Cors.ALL_ORIGINS,
|
|
128
|
+
allowMethods: [...methods, 'OPTIONS'],
|
|
129
|
+
allowHeaders: allowedHeaders ?? apig.Cors.DEFAULT_HEADERS,
|
|
130
|
+
allowCredentials: true,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
methods.forEach(method => resource.addMethod(method, integration, { authorizer }));
|
|
134
|
+
utils.createCfnOutput(`${id}-${path}ResourceId`, scope, resource.resourceId);
|
|
135
|
+
if (addProxy) {
|
|
136
|
+
const resourceProxy = resource.addResource(`{${path}+}`, {
|
|
137
|
+
defaultCorsPreflightOptions: {
|
|
138
|
+
allowOrigins: allowedOrigins ?? apig.Cors.ALL_ORIGINS,
|
|
139
|
+
allowMethods: [...methods, 'OPTIONS'],
|
|
140
|
+
allowHeaders: allowedHeaders ?? apig.Cors.DEFAULT_HEADERS,
|
|
141
|
+
allowCredentials: true,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
methods.forEach(method => resourceProxy.addMethod(method, integration, { authorizer }));
|
|
145
|
+
utils.createCfnOutput(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId);
|
|
146
|
+
}
|
|
147
|
+
return resource;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @summary Method to create an api deployment
|
|
151
|
+
* @param {string} id
|
|
152
|
+
* @param {common.CommonConstruct} scope
|
|
153
|
+
* @param {apig.IRestApi} restApi
|
|
154
|
+
*/
|
|
155
|
+
createApiDeployment(id, scope, restApi) {
|
|
156
|
+
new apig.Deployment(scope, `${id}`, {
|
|
157
|
+
api: restApi,
|
|
158
|
+
retainDeployments: false,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
110
161
|
}
|
|
111
162
|
exports.ApiManager = ApiManager;
|
|
@@ -152,7 +152,8 @@ export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
|
|
|
152
152
|
graphQLVpc: ec2.VpcProps;
|
|
153
153
|
graphQLElastiCache: ElastiCacheProps;
|
|
154
154
|
securityGroupExportName: string;
|
|
155
|
-
|
|
155
|
+
useExistingVpc: boolean;
|
|
156
|
+
vpcName?: string;
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
158
159
|
* @category cdk-utils.api-to-eventbridge-target
|
package/package.json
CHANGED
|
@@ -231,7 +231,15 @@ export class GraphQLApiLambda extends CommonConstruct {
|
|
|
231
231
|
})
|
|
232
232
|
)
|
|
233
233
|
})
|
|
234
|
+
return
|
|
234
235
|
}
|
|
236
|
+
|
|
237
|
+
// add default mapping if apiRootPaths not set
|
|
238
|
+
new apig.BasePathMapping(this, `${this.id}-base-bath-mapping`, {
|
|
239
|
+
domainName: this.graphQLApiDomain,
|
|
240
|
+
restApi: this.graphQLApi,
|
|
241
|
+
stage: this.graphQLApi.deploymentStage,
|
|
242
|
+
})
|
|
235
243
|
}
|
|
236
244
|
|
|
237
245
|
/**
|
|
@@ -37,7 +37,6 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
37
37
|
graphQLVpc: ec2.IVpc
|
|
38
38
|
graphQLElastiCache: elasticache.CfnCacheCluster
|
|
39
39
|
graphQLSecurityGroup: ec2.ISecurityGroup
|
|
40
|
-
securityGroupStackName: string
|
|
41
40
|
securityGroupExportName: string
|
|
42
41
|
vpcExportName: string
|
|
43
42
|
|
|
@@ -60,8 +59,8 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
60
59
|
* @protected
|
|
61
60
|
*/
|
|
62
61
|
protected setVpc() {
|
|
63
|
-
if (this.props.
|
|
64
|
-
this.graphQLVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.
|
|
62
|
+
if (this.props.useExistingVpc) {
|
|
63
|
+
this.graphQLVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.vpcName)
|
|
65
64
|
} else {
|
|
66
65
|
this.graphQLVpc = this.vpcManager.createCommonVpc(this, this.props.graphQLVpc, this.props.graphQLVpc.vpcName)
|
|
67
66
|
}
|
|
@@ -71,7 +71,7 @@ export class ApiManager {
|
|
|
71
71
|
restApiName: `${props.restApiName}-${scope.props.stage}`,
|
|
72
72
|
handler: lambdaFunction,
|
|
73
73
|
defaultCorsPreflightOptions: props.defaultCorsPreflightOptions,
|
|
74
|
-
proxy: props.proxy
|
|
74
|
+
proxy: props.proxy ?? true,
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
utils.createCfnOutput(`${id}-restApiId`, scope, api.restApiId)
|
|
@@ -99,4 +99,70 @@ export class ApiManager {
|
|
|
99
99
|
|
|
100
100
|
return apiDomain
|
|
101
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @summary Method to create an API gateway resource
|
|
105
|
+
* @param {string} id
|
|
106
|
+
* @param {common.CommonConstruct} scope
|
|
107
|
+
* @param {apig.IResource} parent
|
|
108
|
+
* @param {string} path
|
|
109
|
+
* @param {apig.Integration} integration
|
|
110
|
+
* @param {boolean} addProxy
|
|
111
|
+
* @param {apig.IAuthorizer} authorizer
|
|
112
|
+
* @param {string[]?} allowedOrigins
|
|
113
|
+
* @param {string[]?} allowedMethods
|
|
114
|
+
* @param {string[]?} allowedHeaders
|
|
115
|
+
*/
|
|
116
|
+
public createApiResource(
|
|
117
|
+
id: string,
|
|
118
|
+
scope: common.CommonConstruct,
|
|
119
|
+
parent: apig.IResource,
|
|
120
|
+
path: string,
|
|
121
|
+
integration: apig.Integration,
|
|
122
|
+
addProxy: boolean,
|
|
123
|
+
authorizer?: apig.IAuthorizer,
|
|
124
|
+
allowedOrigins?: string[],
|
|
125
|
+
allowedMethods?: string[],
|
|
126
|
+
allowedHeaders?: string[]
|
|
127
|
+
) {
|
|
128
|
+
const methods = allowedMethods ?? apig.Cors.ALL_METHODS
|
|
129
|
+
const resource = parent.addResource(path, {
|
|
130
|
+
defaultCorsPreflightOptions: {
|
|
131
|
+
allowOrigins: allowedOrigins ?? apig.Cors.ALL_ORIGINS,
|
|
132
|
+
allowMethods: [...methods, 'OPTIONS'],
|
|
133
|
+
allowHeaders: allowedHeaders ?? apig.Cors.DEFAULT_HEADERS,
|
|
134
|
+
allowCredentials: true,
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
methods.forEach(method => resource.addMethod(method, integration, { authorizer }))
|
|
138
|
+
utils.createCfnOutput(`${id}-${path}ResourceId`, scope, resource.resourceId)
|
|
139
|
+
|
|
140
|
+
if (addProxy) {
|
|
141
|
+
const resourceProxy = resource.addResource(`{${path}+}`, {
|
|
142
|
+
defaultCorsPreflightOptions: {
|
|
143
|
+
allowOrigins: allowedOrigins ?? apig.Cors.ALL_ORIGINS,
|
|
144
|
+
allowMethods: [...methods, 'OPTIONS'],
|
|
145
|
+
allowHeaders: allowedHeaders ?? apig.Cors.DEFAULT_HEADERS,
|
|
146
|
+
allowCredentials: true,
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
methods.forEach(method => resourceProxy.addMethod(method, integration, { authorizer }))
|
|
150
|
+
utils.createCfnOutput(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return resource
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @summary Method to create an api deployment
|
|
158
|
+
* @param {string} id
|
|
159
|
+
* @param {common.CommonConstruct} scope
|
|
160
|
+
* @param {apig.IRestApi} restApi
|
|
161
|
+
*/
|
|
162
|
+
public createApiDeployment(id: string, scope: common.CommonConstruct, restApi: apig.IRestApi) {
|
|
163
|
+
new apig.Deployment(scope, `${id}`, {
|
|
164
|
+
api: restApi,
|
|
165
|
+
retainDeployments: false,
|
|
166
|
+
})
|
|
167
|
+
}
|
|
102
168
|
}
|
|
@@ -161,7 +161,8 @@ export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
|
|
|
161
161
|
graphQLVpc: ec2.VpcProps
|
|
162
162
|
graphQLElastiCache: ElastiCacheProps
|
|
163
163
|
securityGroupExportName: string
|
|
164
|
-
|
|
164
|
+
useExistingVpc: boolean
|
|
165
|
+
vpcName?: string
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
/**
|