Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OpenSearch Service dedicated master nodes #13

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Pair this pacakge with [@nasa-gcn/architect-functions-search](https://github.com
instanceType t3.small.search
instanceCount 2
availabilityZoneCount 2
# dedicatedMasterCount is optional; if zero or undefined, dedicated
# master nodes are disabled.
dedicatedMasterCount 3
dedicatedMasterType t3.small.search

4. Optionally, create a file called `sandbox-search.json` or `sandbox-search.js` in your project and populate it with sample data to be passed to [`client.bulk()`](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/bulk_examples.html). Here are some examples.

Expand Down
15 changes: 15 additions & 0 deletions service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

export function cloudformationResources({
availabilityZoneCount,
dedicatedMasterCount,
dedicatedMasterType,
instanceCount,
instanceType,
volumeSize,
Expand All @@ -23,6 +25,16 @@ export function cloudformationResources({
const VolumeSize = parseInt(volumeSize)
const ZoneAwarenessEnabled = AvailabilityZoneCount > 1

const DedicatedMasterCount =
(dedicatedMasterCount && parseInt(dedicatedMasterCount)) || undefined
const DedicatedMasterEnabled = Boolean(DedicatedMasterCount)
const DedicatedMasterType = dedicatedMasterType
if (DedicatedMasterEnabled && !DedicatedMasterType) {
throw new Error(
'dedicatedMasterType must be defined because dedicateMasterCount > 0'
)
}

return {
OpenSearchServiceDomain: {
Type: 'AWS::OpenSearchService::Domain',
Expand All @@ -39,6 +51,9 @@ export function cloudformationResources({
],
},
ClusterConfig: {
DedicatedMasterCount,
DedicatedMasterEnabled,
DedicatedMasterType,
InstanceType: instanceType,
InstanceCount,
ZoneAwarenessEnabled,
Expand Down