@gradientedge/cdk-utils 4.8.0 → 4.9.3
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.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 +1 -2
- package/dist/src/lib/manager/aws/api-manager.d.ts +9 -1
- package/dist/src/lib/manager/aws/api-manager.js +16 -3
- 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 +1 -2
- package/src/lib/manager/aws/api-manager.ts +17 -2
|
@@ -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
|
|
@@ -31,7 +31,6 @@ export declare class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
31
31
|
graphQLElastiCache: elasticache.CfnCacheCluster;
|
|
32
32
|
graphQLSecurityGroup: ec2.ISecurityGroup;
|
|
33
33
|
securityGroupExportName: string;
|
|
34
|
-
vpcExportName: string;
|
|
35
34
|
constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps);
|
|
36
35
|
protected initResources(): void;
|
|
37
36
|
/**
|
|
@@ -55,7 +55,6 @@ class GraphQLApiLambdaWithCache extends __1.GraphQLApiLambda {
|
|
|
55
55
|
graphQLElastiCache;
|
|
56
56
|
graphQLSecurityGroup;
|
|
57
57
|
securityGroupExportName;
|
|
58
|
-
vpcExportName;
|
|
59
58
|
constructor(parent, id, props) {
|
|
60
59
|
super(parent, id, props);
|
|
61
60
|
this.props = props;
|
|
@@ -101,7 +100,7 @@ class GraphQLApiLambdaWithCache extends __1.GraphQLApiLambda {
|
|
|
101
100
|
* @protected
|
|
102
101
|
*/
|
|
103
102
|
createElastiCache() {
|
|
104
|
-
this.graphQLElastiCache = this.elasticacheManager.createElastiCache(`${this.id}-elasticache`, this, this.props.graphQLElastiCache, this.graphQLVpc.privateSubnets.map(subnet => subnet.subnetId), [this.graphQLSecurityGroup.
|
|
103
|
+
this.graphQLElastiCache = this.elasticacheManager.createElastiCache(`${this.id}-elasticache`, this, this.props.graphQLElastiCache, this.graphQLVpc.privateSubnets.map(subnet => subnet.subnetId), [this.graphQLSecurityGroup.securityGroupId]);
|
|
105
104
|
}
|
|
106
105
|
/**
|
|
107
106
|
* Create Lambda Role
|
|
@@ -48,9 +48,17 @@ export declare class ApiManager {
|
|
|
48
48
|
* @param {string} path
|
|
49
49
|
* @param {apig.Integration} integration
|
|
50
50
|
* @param {boolean} addProxy
|
|
51
|
+
* @param {apig.IAuthorizer} authorizer
|
|
51
52
|
* @param {string[]?} allowedOrigins
|
|
52
53
|
* @param {string[]?} allowedMethods
|
|
53
54
|
* @param {string[]?} allowedHeaders
|
|
54
55
|
*/
|
|
55
|
-
createApiResource(id: string, scope: common.CommonConstruct, parent: apig.IResource, path: string, integration: apig.Integration, addProxy: boolean, allowedOrigins?: string[], allowedMethods?: string[], allowedHeaders?: string[]): apig.Resource;
|
|
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;
|
|
56
64
|
}
|
|
@@ -115,11 +115,12 @@ class ApiManager {
|
|
|
115
115
|
* @param {string} path
|
|
116
116
|
* @param {apig.Integration} integration
|
|
117
117
|
* @param {boolean} addProxy
|
|
118
|
+
* @param {apig.IAuthorizer} authorizer
|
|
118
119
|
* @param {string[]?} allowedOrigins
|
|
119
120
|
* @param {string[]?} allowedMethods
|
|
120
121
|
* @param {string[]?} allowedHeaders
|
|
121
122
|
*/
|
|
122
|
-
createApiResource(id, scope, parent, path, integration, addProxy, allowedOrigins, allowedMethods, allowedHeaders) {
|
|
123
|
+
createApiResource(id, scope, parent, path, integration, addProxy, authorizer, allowedOrigins, allowedMethods, allowedHeaders) {
|
|
123
124
|
const methods = allowedMethods ?? apig.Cors.ALL_METHODS;
|
|
124
125
|
const resource = parent.addResource(path, {
|
|
125
126
|
defaultCorsPreflightOptions: {
|
|
@@ -129,7 +130,7 @@ class ApiManager {
|
|
|
129
130
|
allowCredentials: true,
|
|
130
131
|
},
|
|
131
132
|
});
|
|
132
|
-
methods.forEach(method => resource.addMethod(method, integration));
|
|
133
|
+
methods.forEach(method => resource.addMethod(method, integration, { authorizer }));
|
|
133
134
|
utils.createCfnOutput(`${id}-${path}ResourceId`, scope, resource.resourceId);
|
|
134
135
|
if (addProxy) {
|
|
135
136
|
const resourceProxy = resource.addResource(`{${path}+}`, {
|
|
@@ -140,10 +141,22 @@ class ApiManager {
|
|
|
140
141
|
allowCredentials: true,
|
|
141
142
|
},
|
|
142
143
|
});
|
|
143
|
-
methods.forEach(method => resourceProxy.addMethod(method, integration));
|
|
144
|
+
methods.forEach(method => resourceProxy.addMethod(method, integration, { authorizer }));
|
|
144
145
|
utils.createCfnOutput(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId);
|
|
145
146
|
}
|
|
146
147
|
return resource;
|
|
147
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
|
+
}
|
|
148
161
|
}
|
|
149
162
|
exports.ApiManager = ApiManager;
|
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
|
/**
|
|
@@ -38,7 +38,6 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
38
38
|
graphQLElastiCache: elasticache.CfnCacheCluster
|
|
39
39
|
graphQLSecurityGroup: ec2.ISecurityGroup
|
|
40
40
|
securityGroupExportName: string
|
|
41
|
-
vpcExportName: string
|
|
42
41
|
|
|
43
42
|
constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps) {
|
|
44
43
|
super(parent, id, props)
|
|
@@ -99,7 +98,7 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
99
98
|
this,
|
|
100
99
|
this.props.graphQLElastiCache,
|
|
101
100
|
this.graphQLVpc.privateSubnets.map(subnet => subnet.subnetId),
|
|
102
|
-
[this.graphQLSecurityGroup.
|
|
101
|
+
[this.graphQLSecurityGroup.securityGroupId]
|
|
103
102
|
)
|
|
104
103
|
}
|
|
105
104
|
|
|
@@ -108,6 +108,7 @@ export class ApiManager {
|
|
|
108
108
|
* @param {string} path
|
|
109
109
|
* @param {apig.Integration} integration
|
|
110
110
|
* @param {boolean} addProxy
|
|
111
|
+
* @param {apig.IAuthorizer} authorizer
|
|
111
112
|
* @param {string[]?} allowedOrigins
|
|
112
113
|
* @param {string[]?} allowedMethods
|
|
113
114
|
* @param {string[]?} allowedHeaders
|
|
@@ -119,6 +120,7 @@ export class ApiManager {
|
|
|
119
120
|
path: string,
|
|
120
121
|
integration: apig.Integration,
|
|
121
122
|
addProxy: boolean,
|
|
123
|
+
authorizer?: apig.IAuthorizer,
|
|
122
124
|
allowedOrigins?: string[],
|
|
123
125
|
allowedMethods?: string[],
|
|
124
126
|
allowedHeaders?: string[]
|
|
@@ -132,7 +134,7 @@ export class ApiManager {
|
|
|
132
134
|
allowCredentials: true,
|
|
133
135
|
},
|
|
134
136
|
})
|
|
135
|
-
methods.forEach(method => resource.addMethod(method, integration))
|
|
137
|
+
methods.forEach(method => resource.addMethod(method, integration, { authorizer }))
|
|
136
138
|
utils.createCfnOutput(`${id}-${path}ResourceId`, scope, resource.resourceId)
|
|
137
139
|
|
|
138
140
|
if (addProxy) {
|
|
@@ -144,10 +146,23 @@ export class ApiManager {
|
|
|
144
146
|
allowCredentials: true,
|
|
145
147
|
},
|
|
146
148
|
})
|
|
147
|
-
methods.forEach(method => resourceProxy.addMethod(method, integration))
|
|
149
|
+
methods.forEach(method => resourceProxy.addMethod(method, integration, { authorizer }))
|
|
148
150
|
utils.createCfnOutput(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId)
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
return resource
|
|
152
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
|
+
}
|
|
153
168
|
}
|