Coder Social home page Coder Social logo

opensearch-bootful's Introduction

Amazon OpenSearch Spring Boot using Spring Data & High Level Rest Client

Connecting to Amazon OpenSearch using Spring Boot using Spring Data and High Level Rest client.

Amazon OpenSearch Https rest calls have to be signed with AWS credentials that will be mapped to a IAMRole with a custom permissions model mapped inside OpenSearch, hence an interceptor is required to sign every API calls with credentials (docs).

This sample code does not secure the Rest API in any way.

In a production environment you could also employ Amazon Cognito or other mechanisms to secure the API and dynamically attach the role to the API depending the logged user following best practices. The project could be integrated with Spring Security in order to gain such features.

Prerequisites

  1. Create an Amazon OpenSearch cluster using this guide.
  2. Follow this blog post in order to setup the required IAM roles used by the app.

Amazon OpenSearch provides the following endpoints

  1. OpenSearch Cluster Rest endpoint
  2. OpenSearch Dashboards endpoint

Config

Provide the following configuration in the application.yml file

  1. aws.os.region=aws-region-you-are-using
  2. aws.os.endpoint=opensearch-domain-endpoint
  3. aws.iamrole=iam-master-role-ARN

This project uses Master IAM Role as it is creating a new index with Fake data. The project is using STS to get credentials for that Role, remember to adapt it for your needs. In the blogpost, the app is launched via Fargate and the Task Role is used for the permission chain.

There are 2 resource flows in this project

  1. CRUD Operation using ElasticsearchRepository - CustomerController
  • To create,update,delete,retrieve data from the indexes
  • The retrieve operation is limited

You can use Postman to interact with the API. The API docs can be seen at http://localhost:8080/swagger-ui/index.html

  1. Live demo with URL: http://localhost:8080/search
  • Start to input some characters in the search box, which will open an auto-complete box of maximum 5 suggestions.
  • Complete the search text and click search button to see the search results.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

opensearch-bootful's People

Contributors

neuw84 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.