From 7c9695a632f499612e6c78c9fee74e55d988786b Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Wed, 4 Oct 2023 14:21:30 -0400 Subject: [PATCH] Add support for OpenSearch Service dedicated master nodes Dedicated master nodes are required for software upgrades without downtime. See documentation: https://docs.aws.amazon.com/opensearch-service/latest/developerguide/version-migration.html --- README.md | 4 ++++ service.ts | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index a6bc281..114537c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/service.ts b/service.ts index 9e6b32c..e6cedf4 100644 --- a/service.ts +++ b/service.ts @@ -8,6 +8,8 @@ export function cloudformationResources({ availabilityZoneCount, + dedicatedMasterCount, + dedicatedMasterType, instanceCount, instanceType, volumeSize, @@ -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', @@ -39,6 +51,9 @@ export function cloudformationResources({ ], }, ClusterConfig: { + DedicatedMasterCount, + DedicatedMasterEnabled, + DedicatedMasterType, InstanceType: instanceType, InstanceCount, ZoneAwarenessEnabled,