Skip to content

High level construct for an AppSync Elasticsearch data source #6063

@bartcallant

Description

@bartcallant

While working on an application I needed to setup an AppSync API which accesses Elasticsearch.

Use Case

Currently this has to be done through the CfnXyz construct. Implementing a higher level construct would simplify the usage of Elasticsearch as a data source.

Proposed Solution

A simple class to create an Elasticsearch data source would do. Implementation could be done similar to the existing DynamoDbDataSource and LambdaDataSource.

Implementation could be as simple as this:

/**
 * Properties for an AppSync Elasticsearch data source
 */
export interface ElasticsearchDataSourceProps extends BaseDataSourceProps {
    /**
     * Region for the Amazon Elasticsearch Service domain
     */
    readonly region: string;
    /**
     * Endpoint for the Amazon Elasticsearch Service domain
     */
    readonly endpoint: string;
}

/**
 * An AppSync data source backed by Elasticsearch
 */
export class ElasticsearchDataSource extends BaseDataSource {
    constructor(scope: Construct, id: string, props: ElasticsearchDataSourceProps) {
        super(scope, id, props, {
            type: 'AMAZON_ELASTICSEARCH',
            elasticsearchConfig: {
                awsRegion: props.region,
                endpoint: props.endpoint
            }
        });
    }
}

Other

There was a PR which already added a base class for a data source> This makes it easy to add a new resolver.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions