Class OpenSearchDataSource

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IGrantable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-21T06:34:03.622Z") @Stability(Stable) public class OpenSearchDataSource extends BackedDataSource
An Appsync datasource backed by OpenSearch.

Example:

 import software.amazon.awscdk.services.opensearchservice.*;
 GraphqlApi api;
 User user = new User(this, "User");
 Domain domain = Domain.Builder.create(this, "Domain")
         .version(EngineVersion.OPENSEARCH_2_3)
         .removalPolicy(RemovalPolicy.DESTROY)
         .fineGrainedAccessControl(AdvancedSecurityOptions.builder().masterUserArn(user.getUserArn()).build())
         .encryptionAtRest(EncryptionAtRestOptions.builder().enabled(true).build())
         .nodeToNodeEncryption(true)
         .enforceHttps(true)
         .build();
 OpenSearchDataSource ds = api.addOpenSearchDataSource("ds", domain);
 ds.createResolver("QueryGetTestsResolver", BaseResolverProps.builder()
         .typeName("Query")
         .fieldName("getTests")
         .requestMappingTemplate(MappingTemplate.fromString(JSON.stringify(Map.of(
                 "version", "2017-02-28",
                 "operation", "GET",
                 "path", "/id/post/_search",
                 "params", Map.of(
                         "headers", Map.of(),
                         "queryString", Map.of(),
                         "body", Map.of("from", 0, "size", 50))))))
         .responseMappingTemplate(MappingTemplate.fromString("[\n    #foreach($entry in $context.result.hits.hits)\n    #if( $velocityCount > 1 ) , #end\n    $utils.toJson($entry.get(\"_source\"))\n    #end\n  ]"))
         .build());
 
  • Constructor Details

    • OpenSearchDataSource

      protected OpenSearchDataSource(software.amazon.jsii.JsiiObjectRef objRef)
    • OpenSearchDataSource

      protected OpenSearchDataSource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • OpenSearchDataSource

      @Stability(Stable) public OpenSearchDataSource(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull OpenSearchDataSourceProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.