Skip to content

Commit

Permalink
chore(opensearchservice): t3 instance type does not support Multi-AZ …
Browse files Browse the repository at this point in the history
…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*
  • Loading branch information
tmokmss authored Mar 28, 2024
1 parent bb1981b commit 8a7c5c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down

0 comments on commit 8a7c5c8

Please sign in to comment.