From 8a7c5c8375d61b1a4d35fa6777b476ab380d40bb Mon Sep 17 00:00:00 2001 From: Masashi Tomooka Date: Fri, 29 Mar 2024 08:15:43 +0900 Subject: [PATCH] chore(opensearchservice): t3 instance type does not support Multi-AZ with standby feature (#29607) ### Issue # (if applicable) Related with #26026 ### Reason for this change #26082 enabled Multi-AZ with Standby by default, but deployment fails if we use t3 instance type, because it does not support the feature. To fail fast, this PR adds validation on synth time. > Multi-AZ with Standby only works with the m5, c5, r5, r6g, c6g, m6g, r6gd and i3 instance types. > https://docs.aws.amazon.com/opensearch-service/latest/developerguide/managedomains-multiaz.html > You can use T3 instance types only if your domain is provisioned without standby. > https://docs.aws.amazon.com/opensearch-service/latest/developerguide/supported-instance-types.html#latest-gen ### Description of changes If the instance type of data node or master node is t3, throws an error. I also considered to automatically set `multiAzWithStandbyEnabled: false` if we detect any t3 instance type, but it would introduce unwanted behavior e.g. in the below case: ```ts // Initial state // multiAzWithStandbyEnabled: true as there's no t3 instance type new Domain(stack, 'Domain', { version: engineVersion, capacity: { dataNodeInstanceType: 'r5.large.search', }, }) // Update domain to add master nodes with t3 instance type new Domain(stack, 'Domain', { version: engineVersion, capacity: { dataNodeInstanceType: 'r5.large.search', masterNodeInstanceType: 't3.medium.search', masterNodes: 3, }, }) // multiAzWithStandbyEnabled suddenly become false! ``` so we just throw an error. ### Description of how you validated changes Added some unit tests. I also confirmed that it results in deployment error if we try to deploy with t3 instance type & `multiAzWithStandbyEnabled : true` for both data node and master node. ### Checklist - [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../aws-opensearchservice/lib/domain.ts | 4 ++++ .../aws-opensearchservice/test/domain.test.ts | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts index 644ff8e3f50fc..c5092fe765818 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts @@ -1828,6 +1828,10 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { } } + if (isSomeInstanceType('t3') && multiAzWithStandbyEnabled) { + throw new Error('T3 instance type does not support Multi-AZ with standby feature.'); + } + const offPeakWindowEnabled = props.offPeakWindowEnabled ?? props.offPeakWindowStart !== undefined; if (offPeakWindowEnabled) { this.validateWindowStartTime(props.offPeakWindowStart); diff --git a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts index 4c7796fe3e5ea..78bbc70afed30 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts @@ -408,6 +408,27 @@ each([testedOpenSearchVersions]).test('can specify multiAZWithStandbyEnabled in }); }); +each([testedOpenSearchVersions]).test('multiAZWithStandbyEnabled: true throws with t3 instance type (data node)', (engineVersion) => { + expect(() => new Domain(stack, 'Domain', { + version: engineVersion, + capacity: { + dataNodeInstanceType: 't3.medium.search', + multiAzWithStandbyEnabled: true, + }, + })).toThrow(/T3 instance type does not support Multi-AZ with standby feature\./); +}); + +each([testedOpenSearchVersions]).test('multiAZWithStandbyEnabled: true throws with t3 instance type (master node)', (engineVersion) => { + expect(() => new Domain(stack, 'Domain', { + version: engineVersion, + capacity: { + masterNodeInstanceType: 't3.medium.search', + masterNodes: 1, + multiAzWithStandbyEnabled: true, + }, + })).toThrow(/T3 instance type does not support Multi-AZ with standby feature\./); +}); + each([testedOpenSearchVersions]).test('ENABLE_OPENSEARCH_MULTIAZ_WITH_STANDBY set multiAZWithStandbyEnabled value', (engineVersion) => { const stackWithFlag = new Stack(app, 'StackWithFlag', { env: { account: '1234', region: 'testregion' },