Skip to content

Commit

Permalink
Add support for OpenSearch Service dedicated master nodes
Browse files Browse the repository at this point in the history
Dedicated master nodes are required for software upgrades without
downtime. See documentation:

https://docs.aws.amazon.com/opensearch-service/latest/developerguide/version-migration.html
  • Loading branch information
lpsinger committed Oct 4, 2023
1 parent b9f5820 commit 7c9695a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit 7c9695a

Please sign in to comment.