Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support r7gd, i4i and i4g in aws_opensearchservice #31563

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CfnDomain } from './opensearchservice.generated';
import * as perms from './perms';
import { EngineVersion } from './version';
import * as acm from '../../aws-certificatemanager';
import { Metric, MetricOptions, Statistic } from '../../aws-cloudwatch';
import { Metric, MetricOptions, Stats } from '../../aws-cloudwatch';
import * as ec2 from '../../aws-ec2';
import * as iam from '../../aws-iam';
import * as kms from '../../aws-kms';
Expand Down Expand Up @@ -1085,7 +1085,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricClusterStatusRed(props?: MetricOptions): Metric {
return this.metric('ClusterStatus.red', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1097,7 +1097,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricClusterStatusYellow(props?: MetricOptions): Metric {
return this.metric('ClusterStatus.yellow', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1109,7 +1109,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricFreeStorageSpace(props?: MetricOptions): Metric {
return this.metric('FreeStorageSpace', {
statistic: Statistic.MINIMUM,
statistic: Stats.MINIMUM,
...props,
});
}
Expand All @@ -1121,7 +1121,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricClusterIndexWritesBlocked(props?: MetricOptions): Metric {
return this.metric('ClusterIndexWritesBlocked', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
period: cdk.Duration.minutes(1),
...props,
});
Expand All @@ -1134,7 +1134,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricNodes(props?: MetricOptions): Metric {
return this.metric('Nodes', {
statistic: Statistic.MINIMUM,
statistic: Stats.MINIMUM,
period: cdk.Duration.hours(1),
...props,
});
Expand All @@ -1147,7 +1147,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricAutomatedSnapshotFailure(props?: MetricOptions): Metric {
return this.metric('AutomatedSnapshotFailure', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1159,7 +1159,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricCPUUtilization(props?: MetricOptions): Metric {
return this.metric('CPUUtilization', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1171,7 +1171,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricJVMMemoryPressure(props?: MetricOptions): Metric {
return this.metric('JVMMemoryPressure', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1183,7 +1183,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricMasterCPUUtilization(props?: MetricOptions): Metric {
return this.metric('MasterCPUUtilization', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1195,7 +1195,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricMasterJVMMemoryPressure(props?: MetricOptions): Metric {
return this.metric('MasterJVMMemoryPressure', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1207,7 +1207,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricKMSKeyError(props?: MetricOptions): Metric {
return this.metric('KMSKeyError', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1219,7 +1219,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricKMSKeyInaccessible(props?: MetricOptions): Metric {
return this.metric('KMSKeyInaccessible', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand All @@ -1231,7 +1231,7 @@ abstract class DomainBase extends cdk.Resource implements IDomain {
*/
public metricSearchableDocuments(props?: MetricOptions): Metric {
return this.metric('SearchableDocuments', {
statistic: Statistic.MAXIMUM,
statistic: Stats.MAXIMUM,
...props,
});
}
Expand Down Expand Up @@ -1513,15 +1513,15 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {

function isInstanceType(t: string): Boolean {
return dedicatedMasterType.startsWith(t) || instanceType.startsWith(t);
};
}

function isSomeInstanceType(...instanceTypes: string[]): Boolean {
return instanceTypes.some(isInstanceType);
};
}

function isEveryDatanodeInstanceType(...instanceTypes: string[]): Boolean {
return instanceTypes.some(t => instanceType.startsWith(t));
};
}

// Validate feature support for the given Elasticsearch/OpenSearch version, per
// https://docs.aws.amazon.com/opensearch-service/latest/developerguide/features-by-version.html
Expand Down Expand Up @@ -1576,8 +1576,8 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {

// Validate against instance type restrictions, per
// https://docs.aws.amazon.com/opensearch-service/latest/developerguide/supported-instance-types.html
if (isSomeInstanceType('i3', 'r6gd', 'im4gn') && ebsEnabled) {
throw new Error('I3, R6GD, and IM4GN instance types do not support EBS storage volumes.');
if (isSomeInstanceType('i3', 'r6gd', 'im4gn', 'i4g', 'i4i', 'r7gd') && ebsEnabled) {
throw new Error('I3, R6GD, IM4GN, I4G, I4I, and R7GD instance types do not support EBS storage volumes.');
}

if (isSomeInstanceType('m3', 'r3', 't2') && encryptionAtRestEnabled) {
Expand All @@ -1594,8 +1594,8 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {

// Only R3, I3, R6GD, and IM4GN support instance storage, per
// https://aws.amazon.com/opensearch-service/pricing/
if (!ebsEnabled && !isEveryDatanodeInstanceType('r3', 'i3', 'r6gd', 'im4gn')) {
throw new Error('EBS volumes are required when using instance types other than R3, I3, R6GD, or IM4GN.');
if (!ebsEnabled && !isEveryDatanodeInstanceType('r3', 'i3', 'r6gd', 'im4gn', 'i4i', 'i4g', 'r7gd')) {
throw new Error('EBS volumes are required when using instance types other than R3, I3, R6GD, IM4GN, I4I, I4G, or R7GD.');
}

// Only for a valid ebs volume configuration, per
Expand Down Expand Up @@ -1738,7 +1738,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
logPublishing.SEARCH_SLOW_LOGS = {
enabled: false,
};
};
}

if (props.logging?.slowIndexLogEnabled) {
this.slowIndexLogGroup = props.logging.slowIndexLogGroup ??
Expand All @@ -1755,7 +1755,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
logPublishing.INDEX_SLOW_LOGS = {
enabled: false,
};
};
}

if (props.logging?.appLogEnabled) {
this.appLogGroup = props.logging.appLogGroup ??
Expand All @@ -1772,7 +1772,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
logPublishing.ES_APPLICATION_LOGS = {
enabled: false,
};
};
}

if (props.logging?.auditLogEnabled) {
this.auditLogGroup = props.logging.auditLogGroup ??
Expand All @@ -1789,7 +1789,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable {
logPublishing.AUDIT_LOGS = {
enabled: false,
};
};
}

let logGroupResourcePolicy: LogGroupResourcePolicy | null = null;
if (logGroups.length > 0 && !props.suppressLogsResourcePolicy) {
Expand Down Expand Up @@ -2120,7 +2120,7 @@ function extractNameFromEndpoint(domainEndpoint: string) {
}

/**
* Converts an engine version into a into a decimal number with major and minor version i.e x.y.
* Converts an engine version into a decimal number with major and minor version i.e x.y.
*
* @param version The engine version object
*/
Expand Down Expand Up @@ -2169,7 +2169,7 @@ function zoneAwarenessCheckShouldBeSkipped(vpc: ec2.IVpc, vpcSubnets: ec2.Subnet
for (const selection of vpcSubnets) {
if (vpc.selectSubnets(selection).isPendingLookup) {
return true;
};
}
}
return false;
}
Expand Down
44 changes: 37 additions & 7 deletions packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
})).toThrow(/Node-to-node encryption requires Elasticsearch version 6.0 or later or OpenSearch version 1.0 or later/);
});

test('error when I3, R6GD, and IM4GN instance types are specified with EBS enabled', () => {
test('error when I3, R6GD, IM4GN, I4G, I4I or R7GD instance types are specified with EBS enabled', () => {
expect(() => new Domain(stack, 'Domain2', {
version: engineVersion,
capacity: {
Expand All @@ -1972,7 +1972,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
volumeSize: 100,
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
},
})).toThrow(/I3, R6GD, and IM4GN instance types do not support EBS storage volumes./);
})).toThrow(/I3, R6GD, IM4GN, I4G, I4I, and R7GD instance types do not support EBS storage volumes./);
expect(() => new Domain(stack, 'Domain3', {
version: engineVersion,
capacity: {
Expand All @@ -1982,7 +1982,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
volumeSize: 100,
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
},
})).toThrow(/I3, R6GD, and IM4GN instance types do not support EBS storage volumes./);
})).toThrow(/I3, R6GD, IM4GN, I4G, I4I, and R7GD instance types do not support EBS storage volumes./);
expect(() => new Domain(stack, 'Domain4', {
version: engineVersion,
capacity: {
Expand All @@ -1992,7 +1992,37 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
volumeSize: 100,
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
},
})).toThrow(/I3, R6GD, and IM4GN instance types do not support EBS storage volumes./);
})).toThrow(/I3, R6GD, IM4GN, I4G, I4I, and R7GD instance types do not support EBS storage volumes./);
expect(() => new Domain(stack, 'Domain5', {
version: engineVersion,
capacity: {
dataNodeInstanceType: 'i4g.2xlarge.search',
},
ebs: {
volumeSize: 100,
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
},
})).toThrow(/I3, R6GD, IM4GN, I4G, I4I, and R7GD instance types do not support EBS storage volumes./);
expect(() => new Domain(stack, 'Domain6', {
version: engineVersion,
capacity: {
dataNodeInstanceType: 'i4i.2xlarge.search',
},
ebs: {
volumeSize: 100,
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
},
})).toThrow(/I3, R6GD, IM4GN, I4G, I4I, and R7GD instance types do not support EBS storage volumes./);
expect(() => new Domain(stack, 'Domain7', {
version: engineVersion,
capacity: {
dataNodeInstanceType: 'r7gd.2xlarge.search',
},
ebs: {
volumeSize: 100,
volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD,
},
})).toThrow(/I3, R6GD, IM4GN, I4G, I4I, and R7GD instance types do not support EBS storage volumes./);
});

test('error when m3, r3, or t2 instance types are specified with encryption at rest enabled', () => {
Expand Down Expand Up @@ -2035,7 +2065,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
})).toThrow(/t2.micro.search instance type supports only Elasticsearch versions 1.5 and 2.3/);
});

test('error when any instance type other than R3, I3, R6GD, or IM4GN are specified without EBS enabled', () => {
test('error when any instance type other than R3, I3, R6GD, IM4GN, I4I, I4G or R7GD are specified without EBS enabled', () => {
expect(() => new Domain(stack, 'Domain1', {
version: engineVersion,
ebs: {
Expand All @@ -2044,7 +2074,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
capacity: {
masterNodeInstanceType: 'm5.large.search',
},
})).toThrow(/EBS volumes are required when using instance types other than R3, I3, R6GD, or IM4GN./);
})).toThrow(/EBS volumes are required when using instance types other than R3, I3, R6GD, IM4GN, I4I, I4G, or R7GD./);
expect(() => new Domain(stack, 'Domain2', {
version: engineVersion,
ebs: {
Expand All @@ -2053,7 +2083,7 @@ each(testedOpenSearchVersions).describe('custom error responses', (engineVersion
capacity: {
dataNodeInstanceType: 'r5.large.search',
},
})).toThrow(/EBS volumes are required when using instance types other than R3, I3, R6GD, or IM4GN./);
})).toThrow(/EBS volumes are required when using instance types other than R3, I3, R6GD, IM4GN, I4I, I4G, or R7GD./);
});

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