Skip to content

Commit e364d2b

Browse files
authored
fix(opensearch): add I4I and R7GD to list of OpenSearch nodes not requiring EBS volumes (#32592)
### Issue # (if applicable) Closes #32070. Closes #32138. ### Reason for this change `I4I` and `R7GD` instances don't require ebs volumes. But at the moment, a domain with `I4I` and `R7GD` instances cannot be deployed. ### Description of changes Added `I4I` and `R7GD` to not requiring EBS volumes instances list. ### Describe any new or updated permissions being added Add unit tests and integ tests. <!— What new or updated IAM permissions are needed to support the changes being introduced ? --> ### Description of how you validated changes ### 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 cb985ba commit e364d2b

File tree

7 files changed

+235
-80
lines changed

7 files changed

+235
-80
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.ebs.js.snapshot/cdk-integ-opensearch-instance-store.assets.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.ebs.js.snapshot/cdk-integ-opensearch-instance-store.template.json

+60-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Resources": {
3-
"Domain66AC69E0": {
3+
"Domain19FCBCB91": {
44
"Type": "AWS::OpenSearchService::Domain",
55
"Properties": {
66
"ClusterConfig": {
@@ -20,7 +20,65 @@
2020
"EncryptionAtRestOptions": {
2121
"Enabled": false
2222
},
23-
"EngineVersion": "OpenSearch_2.5",
23+
"EngineVersion": "OpenSearch_2.17",
24+
"LogPublishingOptions": {},
25+
"NodeToNodeEncryptionOptions": {
26+
"Enabled": false
27+
}
28+
},
29+
"UpdateReplacePolicy": "Delete",
30+
"DeletionPolicy": "Delete"
31+
},
32+
"Domain2644FE48C": {
33+
"Type": "AWS::OpenSearchService::Domain",
34+
"Properties": {
35+
"ClusterConfig": {
36+
"DedicatedMasterEnabled": false,
37+
"InstanceCount": 1,
38+
"InstanceType": "i4i.xlarge.search",
39+
"MultiAZWithStandbyEnabled": false,
40+
"ZoneAwarenessEnabled": false
41+
},
42+
"DomainEndpointOptions": {
43+
"EnforceHTTPS": false,
44+
"TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07"
45+
},
46+
"EBSOptions": {
47+
"EBSEnabled": false
48+
},
49+
"EncryptionAtRestOptions": {
50+
"Enabled": false
51+
},
52+
"EngineVersion": "OpenSearch_2.17",
53+
"LogPublishingOptions": {},
54+
"NodeToNodeEncryptionOptions": {
55+
"Enabled": false
56+
}
57+
},
58+
"UpdateReplacePolicy": "Delete",
59+
"DeletionPolicy": "Delete"
60+
},
61+
"Domain3BE108C7A": {
62+
"Type": "AWS::OpenSearchService::Domain",
63+
"Properties": {
64+
"ClusterConfig": {
65+
"DedicatedMasterEnabled": false,
66+
"InstanceCount": 1,
67+
"InstanceType": "r7gd.xlarge.search",
68+
"MultiAZWithStandbyEnabled": false,
69+
"ZoneAwarenessEnabled": false
70+
},
71+
"DomainEndpointOptions": {
72+
"EnforceHTTPS": false,
73+
"TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07"
74+
},
75+
"EBSOptions": {
76+
"EBSEnabled": false
77+
},
78+
"EncryptionAtRestOptions": {
79+
"Enabled": false
80+
},
81+
"EngineVersion": "OpenSearch_2.17",
2482
"LogPublishingOptions": {},
2583
"NodeToNodeEncryptionOptions": {
2684
"Enabled": false

packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.ebs.js.snapshot/manifest.json

+15-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.ebs.js.snapshot/tree.json

+95-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.ebs.ts

+17-16
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@ class TestStack extends Stack {
77
constructor(scope: Construct, id: string, props?: StackProps) {
88
super(scope, id, props);
99

10-
// deploy the latest opensearch domain with instance store only (no EBS)
11-
const domainProps: opensearch.DomainProps = {
12-
removalPolicy: RemovalPolicy.DESTROY,
13-
version: opensearch.EngineVersion.OPENSEARCH_2_5,
14-
// specify the instance type that supports instance store
15-
capacity: {
16-
multiAzWithStandbyEnabled: false,
17-
dataNodeInstanceType: 'i4g.large.search',
18-
dataNodes: 1,
19-
},
20-
// force ebs configuration to be disabled
21-
ebs: {
22-
enabled: false,
23-
},
24-
};
10+
const instanceTypes = ['i4g.large.search', 'i4i.xlarge.search', 'r7gd.xlarge.search'];
2511

26-
new opensearch.Domain(this, 'Domain', domainProps);
12+
instanceTypes.forEach((instanceType, index) => {
13+
new opensearch.Domain(this, `Domain${index + 1}`, {
14+
removalPolicy: RemovalPolicy.DESTROY,
15+
version: opensearch.EngineVersion.OPENSEARCH_2_17,
16+
// specify the instance type that supports instance store
17+
capacity: {
18+
multiAzWithStandbyEnabled: false,
19+
dataNodeInstanceType: instanceType,
20+
dataNodes: 1,
21+
},
22+
// force ebs configuration to be disabled
23+
ebs: {
24+
enabled: false,
25+
},
26+
});
27+
});
2728
}
2829
}
2930

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

+31-6
Original file line numberDiff line numberDiff line change
@@ -1574,10 +1574,24 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
15741574
}
15751575
}
15761576

1577+
const unSupportEbsInstanceType = [
1578+
ec2.InstanceClass.I3,
1579+
ec2.InstanceClass.R6GD,
1580+
ec2.InstanceClass.I4G,
1581+
ec2.InstanceClass.I4I,
1582+
ec2.InstanceClass.IM4GN,
1583+
ec2.InstanceClass.R7GD,
1584+
];
1585+
1586+
const supportInstanceStorageInstanceType = [
1587+
ec2.InstanceClass.R3,
1588+
...unSupportEbsInstanceType,
1589+
];
1590+
15771591
// Validate against instance type restrictions, per
15781592
// https://docs.aws.amazon.com/opensearch-service/latest/developerguide/supported-instance-types.html
1579-
if (isSomeInstanceType('i3', 'r6gd', 'i4g', 'im4gn') && ebsEnabled) {
1580-
throw new Error('I3, R6GD, I4G, and IM4GN instance types do not support EBS storage volumes.');
1593+
if (isSomeInstanceType(...unSupportEbsInstanceType) && ebsEnabled) {
1594+
throw new Error(`${formatInstanceTypesList(unSupportEbsInstanceType, 'and')} instance types do not support EBS storage volumes.`);
15811595
}
15821596

15831597
if (isSomeInstanceType('m3', 'r3', 't2') && encryptionAtRestEnabled) {
@@ -1592,10 +1606,10 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
15921606
throw new Error('T2 and T3 instance types do not support UltraWarm storage.');
15931607
}
15941608

1595-
// Only R3, I3, R6GD, I4G and IM4GN support instance storage, per
1609+
// Only R3, I3, R6GD, I4G, I4I, IM4GN and R7GD support instance storage, per
15961610
// https://aws.amazon.com/opensearch-service/pricing/
1597-
if (!ebsEnabled && !isEveryDatanodeInstanceType('r3', 'i3', 'r6gd', 'i4g', 'im4gn')) {
1598-
throw new Error('EBS volumes are required when using instance types other than R3, I3, R6GD, I4G, or IM4GN.');
1611+
if (!ebsEnabled && !isEveryDatanodeInstanceType(...supportInstanceStorageInstanceType)) {
1612+
throw new Error(`EBS volumes are required when using instance types other than ${formatInstanceTypesList(supportInstanceStorageInstanceType, 'or')}.`);
15991613
}
16001614

16011615
// Only for a valid ebs volume configuration, per
@@ -1898,7 +1912,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
18981912
identityPoolId: props.cognitoDashboardsAuth?.identityPoolId,
18991913
roleArn: props.cognitoDashboardsAuth?.role.roleArn,
19001914
userPoolId: props.cognitoDashboardsAuth?.userPoolId,
1901-
}: undefined,
1915+
} : undefined,
19021916
vpcOptions: cfnVpcOptions,
19031917
snapshotOptions: props.automatedSnapshotStartHour
19041918
? { automatedSnapshotStartHour: props.automatedSnapshotStartHour }
@@ -2188,3 +2202,14 @@ function initializeInstanceType(defaultInstanceType: string, instanceType?: stri
21882202
return defaultInstanceType;
21892203
}
21902204
}
2205+
2206+
/**
2207+
* Format instance types list for error messages.
2208+
*
2209+
* @param instanceTypes List of instance types to format
2210+
* @param conjunction Word to use as the conjunction (e.g., 'and', 'or')
2211+
* @returns Formatted instance types list for error messages
2212+
*/
2213+
function formatInstanceTypesList(instanceTypes: string[], conjunction: string): string {
2214+
return instanceTypes.map((type) => type.toUpperCase()).join(', ').replace(/, ([^,]*)$/, ` ${conjunction} $1`);
2215+
}

0 commit comments

Comments
 (0)