Skip to content

Commit 034baf3

Browse files
authored
feat(opensearchservice): support OI2 instance type with local NVMe storage (#36700)
### Issue # (if applicable) Closes #36698 ### Reason for this change OI2 is an OpenSearch-specific instance type that uses local NVMe storage and does not support EBS volumes. Currently, CDK validation incorrectly rejects OI2 instance types when ebs: { enabled: false } is specified, throwing: ValidationError: EBS volumes are required when using instance types other than R3, I3, R6GD, I4G, I4I, I8G, IM4GN, R7GD or R8GD. ### Description of changes - Added 'oi2' to the unSupportEbsInstanceType array in domain.ts to recognize OI2 as an instance type that doesn't support EBS (and therefore supports instance storage) - Since OI2 is an OpenSearch-specific instance family (not an EC2 instance class), it's added as a string literal rather than using ec2.InstanceClass - Updated the comment to include OI2 and added a reference to the AWS documentation - Updated unit tests to include OI2 test cases and updated expected error messages ### Describe any new or updated permissions being added N/A - No IAM permission changes. ### Description of how you validated changes - Added unit tests for OI2 instance type: - Error when OI2 is specified with EBS enabled - No error when OI2 is specified without EBS enabled - All existing tests continue to pass ### 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*
1 parent 3462233 commit 034baf3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
16951695
ec2.InstanceClass.IM4GN,
16961696
ec2.InstanceClass.R7GD,
16971697
ec2.InstanceClass.R8GD,
1698+
'oi2', // OpenSearch-specific instance type with local NVMe storage
16981699
];
16991700

17001701
const supportInstanceStorageInstanceType = [
@@ -1731,8 +1732,9 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
17311732
throw new ValidationError(`${formatInstanceTypesList(unSupportUltraWarmInstanceType, 'and')} instance types do not support UltraWarm storage.`, this);
17321733
}
17331734

1734-
// Only R3, I3, R6GD, I4G, I4I, IM4GN and R7GD support instance storage, per
1735+
// Only R3, I3, R6GD, I4G, I4I, I8G, IM4GN, R7GD, R8GD and OI2 support instance storage, per
17351736
// https://aws.amazon.com/opensearch-service/pricing/
1737+
// https://docs.aws.amazon.com/opensearch-service/latest/developerguide/supported-instance-types.html
17361738
if (!ebsEnabled && !isEveryDatanodeInstanceType(...supportInstanceStorageInstanceType)) {
17371739
throw new ValidationError(`EBS volumes are required when using instance types other than ${formatInstanceTypesList(supportInstanceStorageInstanceType, 'or')}.`, this);
17381740
}

packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
20812081
'i8g.4xlarge.search',
20822082
'r7gd.xlarge.search',
20832083
'r8gd.medium.search',
2084+
'oi2.large.search',
20842085
])('error when %s instance type is specified with EBS enabled', (dataNodeInstanceType) => {
20852086
expect(() => new Domain(stack, 'Domain2', {
20862087
version: engineVersion,
@@ -2091,7 +2092,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
20912092
volumeSize: 100,
20922093
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
20932094
},
2094-
})).toThrow(/I3, R6GD, I4G, I4I, I8G, IM4GN, R7GD and R8GD instance types do not support EBS storage volumes./);
2095+
})).toThrow(/I3, R6GD, I4G, I4I, I8G, IM4GN, R7GD, R8GD and OI2 instance types do not support EBS storage volumes./);
20952096
});
20962097

20972098
test.each([
@@ -2103,6 +2104,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
21032104
'i8g.4xlarge.search',
21042105
'r7gd.xlarge.search',
21052106
'r8gd.medium.search',
2107+
'oi2.large.search',
21062108
])('should not throw when %s instance type is specified without EBS enabled', (dataNodeInstanceType) => {
21072109
expect(() => new Domain(stack, 'Domain2', {
21082110
version: engineVersion,
@@ -2142,7 +2144,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
21422144
test.each([
21432145
'm5.large.search',
21442146
'r5.large.search',
2145-
])('error when any instance type other than R3, I3, R6GD, I4I, I4G, IM4GN or R7GD are specified without EBS enabled', (masterNodeInstanceType) => {
2147+
])('error when any instance type other than R3, I3, R6GD, I4I, I4G, I8G, IM4GN, R7GD, R8GD or OI2 are specified without EBS enabled', (masterNodeInstanceType) => {
21462148
expect(() => new Domain(stack, 'Domain1', {
21472149
version: engineVersion,
21482150
ebs: {
@@ -2151,7 +2153,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
21512153
capacity: {
21522154
masterNodeInstanceType,
21532155
},
2154-
})).toThrow(/EBS volumes are required when using instance types other than R3, I3, R6GD, I4G, I4I, I8G, IM4GN, R7GD or R8GD./);
2156+
})).toThrow(/EBS volumes are required when using instance types other than R3, I3, R6GD, I4G, I4I, I8G, IM4GN, R7GD, R8GD or OI2./);
21552157
});
21562158

21572159
test('can use compatible master instance types that does not have local storage when data node type is i3 or r6gd', () => {

0 commit comments

Comments
 (0)