1
1
import { ITable } from '@aws-cdk/aws-dynamodb' ;
2
- import { IDomain } from '@aws-cdk/aws-elasticsearch' ;
2
+ import { IDomain as IElasticsearchDomain } from '@aws-cdk/aws-elasticsearch' ;
3
3
import { IFunction } from '@aws-cdk/aws-lambda' ;
4
+ import { IDomain as IOpenSearchDomain } from '@aws-cdk/aws-opensearchservice' ;
4
5
import { IServerlessCluster } from '@aws-cdk/aws-rds' ;
5
6
import { ISecret } from '@aws-cdk/aws-secretsmanager' ;
6
7
import { CfnResource , IResource , Resource } from '@aws-cdk/core' ;
7
- import { DynamoDbDataSource , HttpDataSource , LambdaDataSource , NoneDataSource , RdsDataSource , AwsIamConfig , ElasticsearchDataSource } from './data-source' ;
8
+ import { DynamoDbDataSource , HttpDataSource , LambdaDataSource , NoneDataSource , RdsDataSource , AwsIamConfig , ElasticsearchDataSource , OpenSearchDataSource } from './data-source' ;
8
9
import { Resolver , ExtendedResolverProps } from './resolver' ;
9
10
10
11
/**
@@ -114,11 +115,21 @@ export interface IGraphqlApi extends IResource {
114
115
/**
115
116
* add a new elasticsearch data source to this API
116
117
*
118
+ * @deprecated - use `addOpenSearchDataSource`
117
119
* @param id The data source's id
118
120
* @param domain The elasticsearch domain for this data source
119
121
* @param options The optional configuration for this data source
120
122
*/
121
- addElasticsearchDataSource ( id : string , domain : IDomain , options ?: DataSourceOptions ) : ElasticsearchDataSource ;
123
+ addElasticsearchDataSource ( id : string , domain : IElasticsearchDomain , options ?: DataSourceOptions ) : ElasticsearchDataSource ;
124
+
125
+ /**
126
+ * Add a new OpenSearch data source to this API
127
+ *
128
+ * @param id The data source's id
129
+ * @param domain The OpenSearch domain for this data source
130
+ * @param options The optional configuration for this data source
131
+ */
132
+ addOpenSearchDataSource ( id : string , domain : IOpenSearchDomain , options ?: DataSourceOptions ) : OpenSearchDataSource ;
122
133
123
134
/**
124
135
* creates a new resolver for this datasource and API using the given properties
@@ -241,11 +252,12 @@ export abstract class GraphqlApiBase extends Resource implements IGraphqlApi {
241
252
/**
242
253
* add a new elasticsearch data source to this API
243
254
*
255
+ * @deprecated - use `addOpenSearchDataSource`
244
256
* @param id The data source's id
245
257
* @param domain The elasticsearch domain for this data source
246
258
* @param options The optional configuration for this data source
247
259
*/
248
- public addElasticsearchDataSource ( id : string , domain : IDomain , options ?: DataSourceOptions ) : ElasticsearchDataSource {
260
+ public addElasticsearchDataSource ( id : string , domain : IElasticsearchDomain , options ?: DataSourceOptions ) : ElasticsearchDataSource {
249
261
return new ElasticsearchDataSource ( this , id , {
250
262
api : this ,
251
263
name : options ?. name ,
@@ -254,6 +266,22 @@ export abstract class GraphqlApiBase extends Resource implements IGraphqlApi {
254
266
} ) ;
255
267
}
256
268
269
+ /**
270
+ * add a new OpenSearch data source to this API
271
+ *
272
+ * @param id The data source's id
273
+ * @param domain The OpenSearch domain for this data source
274
+ * @param options The optional configuration for this data source
275
+ */
276
+ public addOpenSearchDataSource ( id : string , domain : IOpenSearchDomain , options ?: DataSourceOptions ) : OpenSearchDataSource {
277
+ return new OpenSearchDataSource ( this , id , {
278
+ api : this ,
279
+ name : options ?. name ,
280
+ description : options ?. description ,
281
+ domain,
282
+ } ) ;
283
+ }
284
+
257
285
/**
258
286
* creates a new resolver for this datasource and API using the given properties
259
287
*/
@@ -273,4 +301,4 @@ export abstract class GraphqlApiBase extends Resource implements IGraphqlApi {
273
301
construct ;
274
302
return false ;
275
303
}
276
- }
304
+ }
0 commit comments