From 60a050454611f1485ca65e7f60e56f9a1e424f1b Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Thu, 29 Jun 2023 17:54:51 +0000 Subject: [PATCH 01/13] Added support for providing throughput as an option when configuring an opensearch cluster --- .../aws-cdk-lib/aws-opensearchservice/lib/domain.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts index 966998e40360b..eb67e63abfd86 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts @@ -121,13 +121,21 @@ export interface EbsOptions { /** * The number of I/O operations per second (IOPS) that the volume - * supports. This property applies only to the Provisioned IOPS (SSD) EBS + * supports. This property applies only to the gp3 and Provisioned IOPS (SSD) EBS * volume type. * * @default - iops are not set. */ readonly iops?: number; + /** + * The throughput (in MiB/s) of the EBS volumes attached to data nodes. + * This property applies only to the gp3 volume type. + * + * @default - throughput is not set. + */ + readonly throughput?: number; + /** * The size (in GiB) of the EBS volume for each data node. The minimum and * maximum size of an EBS volume depends on the EBS volume type and the @@ -1575,6 +1583,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { volumeSize: ebsEnabled ? volumeSize : undefined, volumeType: ebsEnabled ? volumeType : undefined, iops: ebsEnabled ? props.ebs?.iops : undefined, + throughput: ebsEnabled ? props.ebs?.throughput : undefined, }, encryptionAtRestOptions: { enabled: encryptionAtRestEnabled, From 5d1cf0a94e4b150666cbc5ac3535c73ff11f267e Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Thu, 29 Jun 2023 17:55:22 +0000 Subject: [PATCH 02/13] Integration test for opensearch gp3 --- .../test/integ.opensearch.gp3.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts new file mode 100644 index 0000000000000..1168cbfe193f5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts @@ -0,0 +1,31 @@ +import { App, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import * as opensearch from 'aws-cdk-lib/aws-opensearchservice'; +import { EbsDeviceVolumeType } from 'aws-cdk-lib/aws-ec2'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +class TestStack extends Stack { + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + + // deploy the latest opensearch domain with minimal configuration + // required for gp3 volumes + const domainProps: opensearch.DomainProps = { + removalPolicy: RemovalPolicy.DESTROY, + version: opensearch.EngineVersion.openSearch('2.5'), + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GP3, + throughput: 125, + iops: 3000, + }, + }; + + new opensearch.Domain(this, 'Domain', domainProps); + } +} + +const app = new App(); +const stack = new TestStack(app, 'cdk-integ-opensearch-gp3'); + +new IntegTest(app, 'Integ', { testCases: [stack] }); From 648ef49a699501387fc60a9e086939844214262a Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Thu, 29 Jun 2023 17:58:19 +0000 Subject: [PATCH 03/13] Added integration test snapshot --- ...efaultTestDeployAssert4E6713E1.assets.json | 19 +++ ...aultTestDeployAssert4E6713E1.template.json | 36 +++++ .../cdk-integ-opensearch-gp3.assets.json | 19 +++ .../cdk-integ-opensearch-gp3.template.json | 70 ++++++++ .../integ.opensearch.gp3.js.snapshot/cdk.out | 1 + .../integ.json | 12 ++ .../manifest.json | 111 +++++++++++++ .../tree.json | 149 ++++++++++++++++++ 8 files changed, 417 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json new file mode 100644 index 0000000000000..b4769dfd10a1d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json @@ -0,0 +1,19 @@ +{ + "version": "32.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "IntegDefaultTestDeployAssert4E6713E1.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json new file mode 100644 index 0000000000000..e0f1c09647b59 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json @@ -0,0 +1,19 @@ +{ + "version": "32.0.0", + "files": { + "aa938a4673097be62b5be7544278cf85696c7afb4f575b2b9ce78688a771caf6": { + "source": { + "path": "cdk-integ-opensearch-gp3.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "aa938a4673097be62b5be7544278cf85696c7afb4f575b2b9ce78688a771caf6.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json new file mode 100644 index 0000000000000..b6cb2026fa66f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json @@ -0,0 +1,70 @@ +{ + "Resources": { + "Domain66AC69E0": { + "Type": "AWS::OpenSearchService::Domain", + "Properties": { + "ClusterConfig": { + "DedicatedMasterEnabled": false, + "InstanceCount": 1, + "InstanceType": "r5.large.search", + "ZoneAwarenessEnabled": false + }, + "DomainEndpointOptions": { + "EnforceHTTPS": false, + "TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07" + }, + "EBSOptions": { + "EBSEnabled": true, + "Iops": 3000, + "Throughput": 125, + "VolumeSize": 30, + "VolumeType": "gp3" + }, + "EncryptionAtRestOptions": { + "Enabled": false + }, + "EngineVersion": "OpenSearch_2.5", + "LogPublishingOptions": {}, + "NodeToNodeEncryptionOptions": { + "Enabled": false + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out new file mode 100644 index 0000000000000..f0b901e7c06e5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"32.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json new file mode 100644 index 0000000000000..6e452d3585bb8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "32.0.0", + "testCases": { + "Integ/DefaultTest": { + "stacks": [ + "cdk-integ-opensearch-gp3" + ], + "assertionStack": "Integ/DefaultTest/DeployAssert", + "assertionStackName": "IntegDefaultTestDeployAssert4E6713E1" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json new file mode 100644 index 0000000000000..71c76bc1757d0 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json @@ -0,0 +1,111 @@ +{ + "version": "32.0.0", + "artifacts": { + "cdk-integ-opensearch-gp3.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "cdk-integ-opensearch-gp3.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "cdk-integ-opensearch-gp3": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "cdk-integ-opensearch-gp3.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/aa938a4673097be62b5be7544278cf85696c7afb4f575b2b9ce78688a771caf6.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "cdk-integ-opensearch-gp3.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "cdk-integ-opensearch-gp3.assets" + ], + "metadata": { + "/cdk-integ-opensearch-gp3/Domain/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Domain66AC69E0" + } + ], + "/cdk-integ-opensearch-gp3/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/cdk-integ-opensearch-gp3/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "cdk-integ-opensearch-gp3" + }, + "IntegDefaultTestDeployAssert4E6713E1.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "IntegDefaultTestDeployAssert4E6713E1.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "IntegDefaultTestDeployAssert4E6713E1": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "IntegDefaultTestDeployAssert4E6713E1.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "IntegDefaultTestDeployAssert4E6713E1.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "IntegDefaultTestDeployAssert4E6713E1.assets" + ], + "metadata": { + "/Integ/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/Integ/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "Integ/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json new file mode 100644 index 0000000000000..63915ccdbe9ad --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json @@ -0,0 +1,149 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "cdk-integ-opensearch-gp3": { + "id": "cdk-integ-opensearch-gp3", + "path": "cdk-integ-opensearch-gp3", + "children": { + "Domain": { + "id": "Domain", + "path": "cdk-integ-opensearch-gp3/Domain", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-integ-opensearch-gp3/Domain/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::OpenSearchService::Domain", + "aws:cdk:cloudformation:props": { + "clusterConfig": { + "dedicatedMasterEnabled": false, + "instanceCount": 1, + "instanceType": "r5.large.search", + "zoneAwarenessEnabled": false + }, + "domainEndpointOptions": { + "enforceHttps": false, + "tlsSecurityPolicy": "Policy-Min-TLS-1-0-2019-07" + }, + "ebsOptions": { + "ebsEnabled": true, + "volumeSize": 30, + "volumeType": "gp3", + "iops": 3000, + "throughput": 125 + }, + "encryptionAtRestOptions": { + "enabled": false + }, + "engineVersion": "OpenSearch_2.5", + "logPublishingOptions": {}, + "nodeToNodeEncryptionOptions": { + "enabled": false + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_opensearchservice.CfnDomain", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_opensearchservice.Domain", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-integ-opensearch-gp3/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-integ-opensearch-gp3/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "Integ": { + "id": "Integ", + "path": "Integ", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "Integ/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "Integ/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.55" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "Integ/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "Integ/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "Integ/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.55" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file From 51eb22f29b1c3b2083642f1bb343a7dac2fcdded Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Thu, 29 Jun 2023 18:01:31 +0000 Subject: [PATCH 04/13] Updated README to include instructions on using gp3 volumes --- .../aws-cdk-lib/aws-opensearchservice/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/aws-cdk-lib/aws-opensearchservice/README.md b/packages/aws-cdk-lib/aws-opensearchservice/README.md index 4cc95a5493a85..78b27e2a62058 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/README.md +++ b/packages/aws-cdk-lib/aws-opensearchservice/README.md @@ -22,6 +22,21 @@ const devDomain = new Domain(this, 'Domain', { }); ``` +Create a cluster with GP3 volumes: + +```ts +const gp3Domain = new Domain(this, 'Domain', { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: ec2.EbsDeviceVolumeType.GP3, + throughput: 125, + iops: 3000, + }, +}); +``` + + Create a production grade cluster by also specifying things like capacity and az distribution ```ts From cab621a7e4ba6f13ae5f52d07627e0a1c7a11fbb Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Thu, 29 Jun 2023 18:01:51 +0000 Subject: [PATCH 05/13] Changed test to use ENUM rather than string resolver --- .../test/aws-opensearchservice/test/integ.opensearch.gp3.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts index 1168cbfe193f5..300930ab62604 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.ts @@ -12,7 +12,7 @@ class TestStack extends Stack { // required for gp3 volumes const domainProps: opensearch.DomainProps = { removalPolicy: RemovalPolicy.DESTROY, - version: opensearch.EngineVersion.openSearch('2.5'), + version: opensearch.EngineVersion.OPENSEARCH_2_5, ebs: { volumeSize: 30, volumeType: EbsDeviceVolumeType.GP3, From a0d98981f102094af263aac70ca78a606c7a699c Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Thu, 29 Jun 2023 18:23:31 +0000 Subject: [PATCH 06/13] Removed trailing space --- packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts index eb67e63abfd86..c9ce97b552797 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts @@ -129,7 +129,7 @@ export interface EbsOptions { readonly iops?: number; /** - * The throughput (in MiB/s) of the EBS volumes attached to data nodes. + * The throughput (in MiB/s) of the EBS volumes attached to data nodes. * This property applies only to the gp3 volume type. * * @default - throughput is not set. From 4632845e62ed06b6894248a4b96c54202b11cd59 Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Tue, 4 Jul 2023 18:59:45 +0000 Subject: [PATCH 07/13] Added some EBS Options validation checks and associated unit tests --- .../aws-opensearchservice/lib/domain.ts | 82 +++++++ .../aws-opensearchservice/test/domain.test.ts | 206 +++++++++++++++++- 2 files changed, 287 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts index c9ce97b552797..4b988c17b6e09 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts @@ -1416,6 +1416,88 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { throw new Error('EBS volumes are required when using instance types other than r3, i3 or r6gd.'); } + // Only for a valid ebs volume configuration, per + // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-opensearchservice-domain-ebsoptions.html + if (ebsEnabled) { + // Check if iops or throughput if general purpose is configured + if (volumeType == ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD || volumeType == ec2.EbsDeviceVolumeType.STANDARD) { + if (props.ebs?.iops !== undefined || props.ebs?.throughput !== undefined) { + throw new Error('General Purpose EBS volumes can not be used with Iops or Throughput configuration'); + } + } + + if ( + volumeType && + [ + ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD + ].includes(volumeType) && + !props.ebs?.iops + ) { + throw new Error( + '`iops` must be specified if the `volumeType` is `PROVISIONED_IOPS_SSD`.', + ); + } + if (props.ebs?.iops) { + if ( + ![ + ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2, + ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + ].includes(volumeType) + ) { + throw new Error( + '`iops` may only be specified if the `volumeType` is `PROVISIONED_IOPS_SSD`, `PROVISIONED_IOPS_SSD_IO2` or `GENERAL_PURPOSE_SSD_GP3`.', + ); + } + // Enforce minimum & maximum IOPS: + // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html + const iopsRanges: { [key: string]: { Min: number, Max: number } } = {}; + iopsRanges[ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3] = { Min: 3000, Max: 16000 }; + iopsRanges[ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD] = { Min: 100, Max: 64000 }; + iopsRanges[ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2] = { Min: 100, Max: 64000 }; + const { Min, Max } = iopsRanges[volumeType]; + if (props.ebs?.iops < Min || props.ebs?.iops > Max) { + throw new Error(`\`${volumeType}\` volumes iops must be between ${Min} and ${Max}.`); + } + + // Enforce maximum ratio of IOPS/GiB: + // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html + const maximumRatios: { [key: string]: number } = {}; + maximumRatios[ec2.EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3] = 500; + maximumRatios[ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD] = 50; + maximumRatios[ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2] = 500; + const maximumRatio = maximumRatios[volumeType]; + if (props.ebs?.volumeSize && (props.ebs?.iops > maximumRatio * props.ebs?.volumeSize)) { + throw new Error(`\`${volumeType}\` volumes iops has a maximum ratio of ${maximumRatio} IOPS/GiB.`); + } + + const maximumThroughputRatios: { [key: string]: number } = {}; + maximumThroughputRatios[ec2.EbsDeviceVolumeType.GP3] = 0.25; + const maximumThroughputRatio = maximumThroughputRatios[volumeType]; + if (props.ebs?.throughput && props.ebs?.iops) { + const iopsRatio = (props.ebs?.throughput / props.ebs?.iops); + if (iopsRatio > maximumThroughputRatio) { + throw new Error(`Throughput (MiBps) to iops ratio of ${iopsRatio} is too high; maximum is ${maximumThroughputRatio} MiBps per iops`); + } + } + } + + if (props.ebs?.throughput) { + const throughputRange = { Min: 125, Max: 1000 }; + const { Min, Max } = throughputRange; + if (volumeType != ec2.EbsDeviceVolumeType.GP3) { + throw new Error( + '`throughput` property requires volumeType: `EbsDeviceVolumeType.GP3`', + ); + } + if (props.ebs?.throughput < Min || props.ebs?.throughput > Max) { + throw new Error( + `throughput property takes a minimum of ${Min} and a maximum of ${Max}`, + ); + } + } + } + // Fine-grained access control requires node-to-node encryption, encryption at rest, // and enforced HTTPS. if (advancedSecurityEnabled) { 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 995dae3035ee1..6cb45f9afdd3d 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts @@ -9,7 +9,7 @@ import * as kms from '../../aws-kms'; import * as logs from '../../aws-logs'; import * as route53 from '../../aws-route53'; import { App, Stack, Duration, SecretValue, CfnParameter, Token } from '../../core'; -import { Domain, EngineVersion } from '../lib'; +import { Domain, DomainProps, EngineVersion } from '../lib'; let app: App; let stack: Stack; @@ -1946,6 +1946,210 @@ each(testedOpenSearchVersions).describe('cognito dashboards auth', (engineVersio }); }); +describe('EBS Options Configurations', () => { + + test('iops', () => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + iops: 500, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + }, + }; + new Domain(stack, `Domain`, domainProps); + + Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { + EBSOptions: { + VolumeSize: 30, + Iops: 500, + VolumeType: 'io1', + } + }); + }); + + test('throughput', () => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + throughput: 125, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + }, + }; + new Domain(stack, `Domain`, domainProps); + + Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { + EBSOptions: { + VolumeSize: 30, + Throughput: 125, + VolumeType: 'gp3', + } + }); + }); + + test('throughput and iops', () => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + iops: 3000, + throughput: 125, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + }, + }; + new Domain(stack, `Domain`, domainProps); + + Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { + EBSOptions: { + VolumeSize: 30, + iops: 3000, + Throughput: 125, + VolumeType: 'gp3', + } + }); + }); + + test('validation required props', () => { + let idx: number = 0; + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow('`iops` must be specified if the `volumeType` is `PROVISIONED_IOPS_SSD`.'); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD, + iops: 125, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'General Purpose EBS volumes can not be used with Iops or Throughput configuration' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + iops: 125, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'General Purpose EBS volumes can not be used with Iops or Throughput configuration' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + throughput: 125, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`throughput` property requires volumeType: `EbsDeviceVolumeType.GP3`.' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + iops: 99, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`io1` volumes iops must be between 100 and 64000.' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + iops: 64001, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`io1` volumes iops must be between 100 and 64000.' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + iops: 16001, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`gp3` volumes iops must be between 3000 and 16000.' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + iops: 2999, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`gp3` volumes iops must be between 3000 and 16000.' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + throughput: 1024, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'throughput property takes a minimum of 125 and a maximum of 1000.' + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + throughput: 100, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'throughput property takes a minimum of 125 and a maximum of 1000.' + ); + }); +}); + function testGrant( expectedActions: string[], invocation: (user: iam.IPrincipal, domain: Domain) => void, From 56c6261c48cda0fbd7cbc4ff5e45c62f1c280bf7 Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Tue, 4 Jul 2023 19:23:49 +0000 Subject: [PATCH 08/13] fixed linter issues --- .../aws-opensearchservice/lib/domain.ts | 6 +-- .../aws-opensearchservice/test/domain.test.ts | 40 ++++++------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts index 4b988c17b6e09..b4b714e3c21f6 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts @@ -1429,7 +1429,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { if ( volumeType && [ - ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD + ec2.EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, ].includes(volumeType) && !props.ebs?.iops ) { @@ -1459,7 +1459,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { if (props.ebs?.iops < Min || props.ebs?.iops > Max) { throw new Error(`\`${volumeType}\` volumes iops must be between ${Min} and ${Max}.`); } - + // Enforce maximum ratio of IOPS/GiB: // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html const maximumRatios: { [key: string]: number } = {}; @@ -1470,7 +1470,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { if (props.ebs?.volumeSize && (props.ebs?.iops > maximumRatio * props.ebs?.volumeSize)) { throw new Error(`\`${volumeType}\` volumes iops has a maximum ratio of ${maximumRatio} IOPS/GiB.`); } - + const maximumThroughputRatios: { [key: string]: number } = {}; maximumThroughputRatios[ec2.EbsDeviceVolumeType.GP3] = 0.25; const maximumThroughputRatio = maximumThroughputRatios[volumeType]; 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 6cb45f9afdd3d..5fa4d93c71349 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts @@ -1957,14 +1957,14 @@ describe('EBS Options Configurations', () => { volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, }, }; - new Domain(stack, `Domain`, domainProps); + new Domain(stack, 'Domain', domainProps); Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { EBSOptions: { VolumeSize: 30, Iops: 500, VolumeType: 'io1', - } + }, }); }); @@ -1977,14 +1977,14 @@ describe('EBS Options Configurations', () => { volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, }, }; - new Domain(stack, `Domain`, domainProps); + new Domain(stack, 'Domain', domainProps); Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { EBSOptions: { VolumeSize: 30, Throughput: 125, VolumeType: 'gp3', - } + }, }); }); @@ -1998,7 +1998,7 @@ describe('EBS Options Configurations', () => { volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, }, }; - new Domain(stack, `Domain`, domainProps); + new Domain(stack, 'Domain', domainProps); Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { EBSOptions: { @@ -2006,7 +2006,7 @@ describe('EBS Options Configurations', () => { iops: 3000, Throughput: 125, VolumeType: 'gp3', - } + }, }); }); @@ -2034,9 +2034,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'General Purpose EBS volumes can not be used with Iops or Throughput configuration' - ); + }).toThrow('General Purpose EBS volumes can not be used with Iops or Throughput configuration'); expect(() => { const domainProps: DomainProps = { @@ -2046,9 +2044,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'General Purpose EBS volumes can not be used with Iops or Throughput configuration' - ); + }).toThrow('General Purpose EBS volumes can not be used with Iops or Throughput configuration'); expect(() => { const domainProps: DomainProps = { @@ -2060,9 +2056,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`throughput` property requires volumeType: `EbsDeviceVolumeType.GP3`.' - ); + }).toThrow('`throughput` property requires volumeType: `EbsDeviceVolumeType.GP3`.'); expect(() => { const domainProps: DomainProps = { @@ -2074,9 +2068,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`io1` volumes iops must be between 100 and 64000.' - ); + }).toThrow('`io1` volumes iops must be between 100 and 64000.'); expect(() => { const domainProps: DomainProps = { @@ -2088,9 +2080,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`io1` volumes iops must be between 100 and 64000.' - ); + }).toThrow('`io1` volumes iops must be between 100 and 64000.'); expect(() => { const domainProps: DomainProps = { @@ -2116,9 +2106,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`gp3` volumes iops must be between 3000 and 16000.' - ); + }).toThrow('`gp3` volumes iops must be between 3000 and 16000.'); expect(() => { const domainProps: DomainProps = { @@ -2144,9 +2132,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'throughput property takes a minimum of 125 and a maximum of 1000.' - ); + }).toThrow('throughput property takes a minimum of 125 and a maximum of 1000.'); }); }); From 6e6f3989806b5476a69ec538cc6d167e22079daf Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Wed, 5 Jul 2023 05:38:48 +1000 Subject: [PATCH 09/13] another lint fix --- .../aws-cdk-lib/aws-opensearchservice/test/domain.test.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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 5fa4d93c71349..982e4f7eec5f7 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts @@ -2092,9 +2092,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`gp3` volumes iops must be between 3000 and 16000.' - ); + }).toThrow('`gp3` volumes iops must be between 3000 and 16000.'); expect(() => { const domainProps: DomainProps = { @@ -2118,9 +2116,7 @@ describe('EBS Options Configurations', () => { }, }; new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'throughput property takes a minimum of 125 and a maximum of 1000.' - ); + }).toThrow('throughput property takes a minimum of 125 and a maximum of 1000.'); expect(() => { const domainProps: DomainProps = { From 2681b5572445ffc1c6d32cb51bf9a9ea98a63555 Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Wed, 5 Jul 2023 00:54:32 +0000 Subject: [PATCH 10/13] fixed tests --- .../aws-opensearchservice/test/domain.test.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) 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 982e4f7eec5f7..8d758d7d7512d 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/test/domain.test.ts @@ -2003,7 +2003,7 @@ describe('EBS Options Configurations', () => { Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { EBSOptions: { VolumeSize: 30, - iops: 3000, + Iops: 3000, Throughput: 125, VolumeType: 'gp3', }, @@ -2046,18 +2046,6 @@ describe('EBS Options Configurations', () => { new Domain(stack, `Domain${idx++}`, domainProps); }).toThrow('General Purpose EBS volumes can not be used with Iops or Throughput configuration'); - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - throughput: 125, - volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow('`throughput` property requires volumeType: `EbsDeviceVolumeType.GP3`.'); - expect(() => { const domainProps: DomainProps = { version: EngineVersion.OPENSEARCH_2_5, From 81419f323169bc1ee1513445d7ae9738c2c36cdf Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Wed, 5 Jul 2023 01:17:47 +0000 Subject: [PATCH 11/13] Forgot to include the changed library --- packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts index b4b714e3c21f6..9d4e44d824d33 100644 --- a/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts +++ b/packages/aws-cdk-lib/aws-opensearchservice/lib/domain.ts @@ -1477,7 +1477,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { if (props.ebs?.throughput && props.ebs?.iops) { const iopsRatio = (props.ebs?.throughput / props.ebs?.iops); if (iopsRatio > maximumThroughputRatio) { - throw new Error(`Throughput (MiBps) to iops ratio of ${iopsRatio} is too high; maximum is ${maximumThroughputRatio} MiBps per iops`); + throw new Error(`Throughput (MiBps) to iops ratio of ${iopsRatio} is too high; maximum is ${maximumThroughputRatio} MiBps per iops.`); } } } @@ -1492,7 +1492,7 @@ export class Domain extends DomainBase implements IDomain, ec2.IConnectable { } if (props.ebs?.throughput < Min || props.ebs?.throughput > Max) { throw new Error( - `throughput property takes a minimum of ${Min} and a maximum of ${Max}`, + `throughput property takes a minimum of ${Min} and a maximum of ${Max}.`, ); } } From 43553b310a973feb39f8faad497e1ecaf1e28cb9 Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Mon, 7 Aug 2023 01:10:02 +0000 Subject: [PATCH 12/13] Updated tests after merge conflict --- ...efaultTestDeployAssert4E6713E1.assets.json | 2 +- .../cdk-integ-opensearch-gp3.assets.json | 6 +- .../cdk-integ-opensearch-gp3.template.json | 1 + .../integ.opensearch.gp3.js.snapshot/cdk.out | 2 +- .../integ.json | 2 +- .../manifest.json | 4 +- .../tree.json | 5 +- .../test/ebsoptions.test.ts | 207 ++++++++++++++++++ 8 files changed, 219 insertions(+), 10 deletions(-) create mode 100644 packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json index b4769dfd10a1d..cb12f699bfe4a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/IntegDefaultTestDeployAssert4E6713E1.assets.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json index e0f1c09647b59..fd4931cecfbb1 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.assets.json @@ -1,7 +1,7 @@ { - "version": "32.0.0", + "version": "33.0.0", "files": { - "aa938a4673097be62b5be7544278cf85696c7afb4f575b2b9ce78688a771caf6": { + "213b01de3bb16c293563a528b8be2db8d685bf9228b484f6c369e8ce3f9f3958": { "source": { "path": "cdk-integ-opensearch-gp3.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "aa938a4673097be62b5be7544278cf85696c7afb4f575b2b9ce78688a771caf6.json", + "objectKey": "213b01de3bb16c293563a528b8be2db8d685bf9228b484f6c369e8ce3f9f3958.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json index b6cb2026fa66f..c07127843390a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk-integ-opensearch-gp3.template.json @@ -7,6 +7,7 @@ "DedicatedMasterEnabled": false, "InstanceCount": 1, "InstanceType": "r5.large.search", + "MultiAZWithStandbyEnabled": true, "ZoneAwarenessEnabled": false }, "DomainEndpointOptions": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out index f0b901e7c06e5..560dae10d018f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"32.0.0"} \ No newline at end of file +{"version":"33.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json index 6e452d3585bb8..5a21b6845b50a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "testCases": { "Integ/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json index 71c76bc1757d0..6ab669045facc 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "artifacts": { "cdk-integ-opensearch-gp3.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/aa938a4673097be62b5be7544278cf85696c7afb4f575b2b9ce78688a771caf6.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/213b01de3bb16c293563a528b8be2db8d685bf9228b484f6c369e8ce3f9f3958.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json index 63915ccdbe9ad..ca1e108b0f69a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-opensearchservice/test/integ.opensearch.gp3.js.snapshot/tree.json @@ -22,6 +22,7 @@ "dedicatedMasterEnabled": false, "instanceCount": 1, "instanceType": "r5.large.search", + "multiAzWithStandbyEnabled": true, "zoneAwarenessEnabled": false }, "domainEndpointOptions": { @@ -91,7 +92,7 @@ "path": "Integ/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } }, "DeployAssert": { @@ -137,7 +138,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } } }, diff --git a/packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts b/packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts new file mode 100644 index 0000000000000..6f2839ec78c73 --- /dev/null +++ b/packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts @@ -0,0 +1,207 @@ +/* eslint-disable jest/expect-expect */ +import { Template } from '../../assertions'; +import { EbsDeviceVolumeType } from '../../aws-ec2'; +import { App, Stack } from '../../core'; +import { Domain, DomainProps, EngineVersion } from '../lib'; + +let app: App; +let stack: Stack; + +beforeEach(() => { + app = new App(); + stack = new Stack(app, 'Stack', { + env: { account: '1234', region: 'testregion' }, + }); + + jest.resetAllMocks(); +}); + +describe('EBS Options Configurations', () => { + + test('iops', () => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + iops: 500, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + }, + }; + new Domain(stack, 'Domain', domainProps); + + Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { + EBSOptions: { + VolumeSize: 30, + Iops: 500, + VolumeType: 'io1', + }, + }); + }); + + test('throughput', () => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + throughput: 125, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + }, + }; + new Domain(stack, 'Domain', domainProps); + + Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { + EBSOptions: { + VolumeSize: 30, + Throughput: 125, + VolumeType: 'gp3', + }, + }); + }); + + test('throughput and iops', () => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + iops: 3000, + throughput: 125, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + }, + }; + new Domain(stack, 'Domain', domainProps); + + Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { + EBSOptions: { + VolumeSize: 30, + iops: 3000, + Throughput: 125, + VolumeType: 'gp3', + }, + }); + }); + + test('validation required props', () => { + let idx: number = 0; + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow('`iops` must be specified if the `volumeType` is `PROVISIONED_IOPS_SSD`.'); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD, + iops: 125, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'General Purpose EBS volumes can not be used with Iops or Throughput configuration', + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + iops: 125, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'General Purpose EBS volumes can not be used with Iops or Throughput configuration', + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + iops: 99, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`io1` volumes iops must be between 100 and 64000.', + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, + iops: 64001, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`io1` volumes iops must be between 100 and 64000.', + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + iops: 16001, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`gp3` volumes iops must be between 3000 and 16000.', + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + iops: 2999, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + '`gp3` volumes iops must be between 3000 and 16000.', + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + throughput: 1024, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'throughput property takes a minimum of 125 and a maximum of 1000.', + ); + + expect(() => { + const domainProps: DomainProps = { + version: EngineVersion.OPENSEARCH_2_5, + ebs: { + volumeSize: 30, + volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, + throughput: 100, + }, + }; + new Domain(stack, `Domain${idx++}`, domainProps); + }).toThrow( + 'throughput property takes a minimum of 125 and a maximum of 1000.', + ); + }); +}); From a2232154c5694cb3bdc598f38bc2735e78d9f09d Mon Sep 17 00:00:00 2001 From: Steven Tan Date: Mon, 7 Aug 2023 01:10:57 +0000 Subject: [PATCH 13/13] Removed unnessecary test file --- .../test/ebsoptions.test.ts | 207 ------------------ 1 file changed, 207 deletions(-) delete mode 100644 packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts diff --git a/packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts b/packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts deleted file mode 100644 index 6f2839ec78c73..0000000000000 --- a/packages/aws-cdk-lib/aws-opensearchservice/test/ebsoptions.test.ts +++ /dev/null @@ -1,207 +0,0 @@ -/* eslint-disable jest/expect-expect */ -import { Template } from '../../assertions'; -import { EbsDeviceVolumeType } from '../../aws-ec2'; -import { App, Stack } from '../../core'; -import { Domain, DomainProps, EngineVersion } from '../lib'; - -let app: App; -let stack: Stack; - -beforeEach(() => { - app = new App(); - stack = new Stack(app, 'Stack', { - env: { account: '1234', region: 'testregion' }, - }); - - jest.resetAllMocks(); -}); - -describe('EBS Options Configurations', () => { - - test('iops', () => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - iops: 500, - volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, - }, - }; - new Domain(stack, 'Domain', domainProps); - - Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { - EBSOptions: { - VolumeSize: 30, - Iops: 500, - VolumeType: 'io1', - }, - }); - }); - - test('throughput', () => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - throughput: 125, - volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, - }, - }; - new Domain(stack, 'Domain', domainProps); - - Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { - EBSOptions: { - VolumeSize: 30, - Throughput: 125, - VolumeType: 'gp3', - }, - }); - }); - - test('throughput and iops', () => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - iops: 3000, - throughput: 125, - volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, - }, - }; - new Domain(stack, 'Domain', domainProps); - - Template.fromStack(stack).hasResourceProperties('AWS::OpenSearchService::Domain', { - EBSOptions: { - VolumeSize: 30, - iops: 3000, - Throughput: 125, - VolumeType: 'gp3', - }, - }); - }); - - test('validation required props', () => { - let idx: number = 0; - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow('`iops` must be specified if the `volumeType` is `PROVISIONED_IOPS_SSD`.'); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD, - iops: 125, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'General Purpose EBS volumes can not be used with Iops or Throughput configuration', - ); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - iops: 125, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'General Purpose EBS volumes can not be used with Iops or Throughput configuration', - ); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, - iops: 99, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`io1` volumes iops must be between 100 and 64000.', - ); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, - iops: 64001, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`io1` volumes iops must be between 100 and 64000.', - ); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, - iops: 16001, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`gp3` volumes iops must be between 3000 and 16000.', - ); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, - iops: 2999, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - '`gp3` volumes iops must be between 3000 and 16000.', - ); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, - throughput: 1024, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'throughput property takes a minimum of 125 and a maximum of 1000.', - ); - - expect(() => { - const domainProps: DomainProps = { - version: EngineVersion.OPENSEARCH_2_5, - ebs: { - volumeSize: 30, - volumeType: EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, - throughput: 100, - }, - }; - new Domain(stack, `Domain${idx++}`, domainProps); - }).toThrow( - 'throughput property takes a minimum of 125 and a maximum of 1000.', - ); - }); -});