{"id":15068796,"url":"https://github.com/ethan-pritchard/aws-qbusiness-java-boilerplate","last_synced_at":"2026-01-02T08:40:25.823Z","repository":{"id":251460078,"uuid":"837422577","full_name":"ethan-pritchard/aws-qbusiness-java-boilerplate","owner":"ethan-pritchard","description":"A java boilerplate for AWS Q Business infrastructure using a custom data source connector.","archived":false,"fork":false,"pushed_at":"2024-08-03T18:25:28.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T21:22:03.500Z","etag":null,"topics":["amazon-q-business","aws","aws-lambda","aws-sfn","java","java11","maven"],"latest_commit_sha":null,"homepage":"https://github.com/ethan-pritchard/aws-qbusiness-java-boilerplate","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethan-pritchard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-03T00:21:10.000Z","updated_at":"2025-01-15T20:08:55.000Z","dependencies_parsed_at":"2024-08-03T07:24:11.053Z","dependency_job_id":"45c49536-425d-4245-8ec4-4bebaadcb18a","html_url":"https://github.com/ethan-pritchard/aws-qbusiness-java-boilerplate","commit_stats":null,"previous_names":["ethan-pritchard/aws-qbusiness-java-boilerplate"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan-pritchard%2Faws-qbusiness-java-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan-pritchard%2Faws-qbusiness-java-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan-pritchard%2Faws-qbusiness-java-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan-pritchard%2Faws-qbusiness-java-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethan-pritchard","download_url":"https://codeload.github.com/ethan-pritchard/aws-qbusiness-java-boilerplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847057,"owners_count":20357317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-q-business","aws","aws-lambda","aws-sfn","java","java11","maven"],"created_at":"2024-09-25T01:39:18.460Z","updated_at":"2026-01-02T08:40:25.769Z","avatar_url":"https://github.com/ethan-pritchard.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aws-qbusiness-java-boilerplate\nA java boilerplate for \n[AWS Q Business](https://aws.amazon.com/q/business/) \ninfrastructure using a \n[custom data source connector](https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/custom-connector.html).\n\n## Getting Started\nThis boilerplate has two todos:\n- [Fetch persistence w/ nextToken (optional) and startTime (if not -1)](/src/main/java/com/ethanpritchard/example/handlers/BatchDocumentHandler.java)\n  - Depending on how your data is persisted, you will have to use an API or a client to fetch it. \n    - If paginated, this API or client will consume `nextToken` and give a new `nextToken`.\n- [Convert persistence -\u003e Q Business Document](/src/main/java/com/ethanpritchard/example/handlers/BatchDocumentHandler.java)\n  - AWS Q Business requires your data to be a [Document structure](https://docs.aws.amazon.com/amazonq/latest/api-reference/API_Document.html) which supports content types such as PDF, HTML, JSON, and more.\n\n## Workflows\n### Batch Processing Workflow\nAn AWS Step Function state machine which when executed:\n- Manages the AWS Q Business data source sync job lifecycle (start, stop)\n- Calls BatchDocument which fetches documents from your persistence, transforms documents into AWS Q Business Documents, and uses [`qbusiness:BatchPutDocument`](https://docs.aws.amazon.com/amazonq/latest/api-reference/API_BatchPutDocument.html) to iteratively index AWS Q Business Documents\n\nThis boilerplate demonstrates its flexibility by adding pagination support with the following modifications:\n- Added parameters `maxPages` `nextToken` `startDate` `endDate`\n- Modified BatchDocument in order to:\n  - Consume `nextToken` `startDate` `endDate` in the request\n  - Output a `nextToken` if applicable\n  - Passthrough `startDate` `endDate` into the response\n- Modified batch processing state machine in order to recursively increment the `currentPage` for each BatchDocument request\n- Modified batch processing state machine in order to recursively call BatchDocument with the refreshed `nextToken` until `currentPage` exceeds `maxPages` or `nextToken` is `\"\"`\n\nFor larger workflows, I recommend the\n[AWS Step Functions Parallel state](https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-parallel-state.html)\ninstead of recursion.\n\n![alt](https://i.imgur.com/UxlJf2Y.png)\n\n#### How To Use\nTrigger `TriggerBatchProcessingStateMachineFunction` with this input:\n```\n{\n    \"applicationId\": \"Q Business application Id\",\n    \"dataSourceId\": \"Q Business data source Id\",\n    \"indexId\": \"Q Business index Id\",\n    \"maxPages\": Max nextTokens to consume,\n    \"nextToken\": \"\" OR Paginated next token,\n    \"startDate\": -1 OR Valid timestamp,\n    \"endDate\": -1 OR Valid timestamp\n}\n```\nThere are four configurations of parameters for the `TriggerBatchProcessingStateMachineFunction`:\n- `nextToken` is `\"\"`. `startDate`/`endDate` are `-1`\n  - Starts at beginning of pagination API\n- `nextToken` is `\"\"`. `startDate`/`endDate` are `timestamp`\n  - Starts at beginning of timeframe filtered pagination API\n- `nextToken` is `paginated next token`. `startDate`/`endDate` are `-1`\n  - Starts at pagination next token of pagination API\n- `nextToken` is `paginated next token`. `startDate`/`endDate` are `timestamp`\n  - Starts at pagination next token of timeframe filtered pagination API\n\nOptionally, add automation using [AWS EventBridge Scheduler](https://docs.aws.amazon.com/lambda/latest/dg/with-eventbridge-scheduler.html) to trigger `TriggerBatchProcessingStateMachineFunction` on a schedule.\n\nThe `BatchProcessingStateMachine` will recursively call the pagination API until\n- `maxPages` is reached, or\n- `nextToken` output from `BatchDocumentLambda` is `\"\"`\n\n## Deployment\n- `aws s3api create-bucket --bucket \u003cbucket name\u003e`\n- `aws cloudformation package --template-file ./cfn/template.json --s3-bucket \u003cbucket name\u003e --output-template-file ./target/template.json`\n- `aws cloudformation deploy --template-file ./target/template.json --capabilities \"CAPABILITY_NAMED_IAM\" --stack-name \u003cstack name\u003e` and optionally adding `--parameter-overrides IdCInstanceArn=\u003cidc instance arn\u003e`\n\n## License\n[LICENSE](/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethan-pritchard%2Faws-qbusiness-java-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethan-pritchard%2Faws-qbusiness-java-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethan-pritchard%2Faws-qbusiness-java-boilerplate/lists"}