From 8ecf0b7a3e54794a46ecc2af209eeac8f1babef4 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 13:11:10 -0600 Subject: [PATCH 01/12] #26045 resource schema and implementation --- internal/service/opensearch/domain.go | 6 ++++++ internal/service/opensearch/flex.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/internal/service/opensearch/domain.go b/internal/service/opensearch/domain.go index caef55a60a4..72622305bbc 100644 --- a/internal/service/opensearch/domain.go +++ b/internal/service/opensearch/domain.go @@ -384,6 +384,12 @@ func ResourceDomain() *schema.Resource { Type: schema.TypeInt, Optional: true, }, + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntBetween(125, 1000), + }, "volume_size": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/opensearch/flex.go b/internal/service/opensearch/flex.go index c873877d22c..9ed97c19797 100644 --- a/internal/service/opensearch/flex.go +++ b/internal/service/opensearch/flex.go @@ -80,6 +80,9 @@ func expandEBSOptions(m map[string]interface{}) *opensearchservice.EBSOptions { if v, ok := m["iops"]; ok && v.(int) > 0 { options.Iops = aws.Int64(int64(v.(int))) } + if v, ok := m["throughput"]; ok && v.(int) > 0 { + options.Throughput = aws.Int64(int64(v.(int))) + } if v, ok := m["volume_size"]; ok && v.(int) > 0 { options.VolumeSize = aws.Int64(int64(v.(int))) } @@ -165,6 +168,9 @@ func flattenEBSOptions(o *opensearchservice.EBSOptions) []map[string]interface{} if o.Iops != nil { m["iops"] = aws.Int64Value(o.Iops) } + if o.Throughput != nil { + m["throughput"] = aws.Int64Value(o.Throughput) + } if o.VolumeSize != nil { m["volume_size"] = aws.Int64Value(o.VolumeSize) } From 6a1be8cfdab40c7878ef3591a15eeee3796d7e35 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 13:11:24 -0600 Subject: [PATCH 02/12] #26045 data schema --- internal/service/opensearch/domain_data_source.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/service/opensearch/domain_data_source.go b/internal/service/opensearch/domain_data_source.go index 1d85fe46ad4..4756f17a040 100644 --- a/internal/service/opensearch/domain_data_source.go +++ b/internal/service/opensearch/domain_data_source.go @@ -123,6 +123,10 @@ func DataSourceDomain() *schema.Resource { Type: schema.TypeInt, Computed: true, }, + "throughput": { + Type: schema.TypeInt, + Computed: true, + }, "volume_size": { Type: schema.TypeInt, Computed: true, From 74d489116ced59e28f1e14565fb4fe8ea74e7912 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 13:11:37 -0600 Subject: [PATCH 03/12] #26045 resource docs --- website/docs/r/opensearch_domain.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/opensearch_domain.html.markdown b/website/docs/r/opensearch_domain.html.markdown index e667723a8ae..d7ebf3e919a 100644 --- a/website/docs/r/opensearch_domain.html.markdown +++ b/website/docs/r/opensearch_domain.html.markdown @@ -311,6 +311,7 @@ AWS documentation: [Amazon Cognito Authentication for Kibana](https://docs.aws.a * `ebs_enabled` - (Required) Whether EBS volumes are attached to data nodes in the domain. * `iops` - (Optional) Baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the Provisioned IOPS EBS volume type. +* `throughput` - (Required if `volume_type` is set to `gp3`) Specifies the throughput (in MiB/s) of the EBS volumes attached to data nodes. Applicable only for the gp3 volume type. Valid values are between `125` and `1000` * `volume_size` - (Required if `ebs_enabled` is set to `true`.) Size of EBS volumes attached to data nodes (in GiB). * `volume_type` - (Optional) Type of EBS volumes attached to data nodes. From fe071f967dd5249c70dc55d56a594d7f19474c6c Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 13:21:29 -0600 Subject: [PATCH 04/12] #26045 resource docs --- website/docs/r/opensearch_domain.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/opensearch_domain.html.markdown b/website/docs/r/opensearch_domain.html.markdown index d7ebf3e919a..0bed22d4e6e 100644 --- a/website/docs/r/opensearch_domain.html.markdown +++ b/website/docs/r/opensearch_domain.html.markdown @@ -310,7 +310,7 @@ AWS documentation: [Amazon Cognito Authentication for Kibana](https://docs.aws.a ### ebs_options * `ebs_enabled` - (Required) Whether EBS volumes are attached to data nodes in the domain. -* `iops` - (Optional) Baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the Provisioned IOPS EBS volume type. +* `iops` - (Optional) Baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the GP3 and Provisioned IOPS EBS volume types. * `throughput` - (Required if `volume_type` is set to `gp3`) Specifies the throughput (in MiB/s) of the EBS volumes attached to data nodes. Applicable only for the gp3 volume type. Valid values are between `125` and `1000` * `volume_size` - (Required if `ebs_enabled` is set to `true`.) Size of EBS volumes attached to data nodes (in GiB). * `volume_type` - (Optional) Type of EBS volumes attached to data nodes. From a0d55daae4ed6e9920eb1d4851e4e3a6c75e1631 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 13:23:16 -0600 Subject: [PATCH 05/12] #26045 data docs --- website/docs/d/opensearch_domain.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/d/opensearch_domain.html.markdown b/website/docs/d/opensearch_domain.html.markdown index 0dd5e78282b..d1bdd3c272d 100644 --- a/website/docs/d/opensearch_domain.html.markdown +++ b/website/docs/d/opensearch_domain.html.markdown @@ -68,6 +68,7 @@ The following attributes are exported: * `domain_id` – Unique identifier for the domain. * `ebs_options` - EBS Options for the instances in the domain. * `ebs_enabled` - Whether EBS volumes are attached to data nodes in the domain. + * `throughput` - The throughput (in MiB/s) of the EBS volumes attached to data nodes. * `volume_type` - Type of EBS volumes attached to data nodes. * `volume_size` - Size of EBS volumes attached to data nodes (in GB). * `iops` - Baseline input/output (I/O) performance of EBS volumes attached to data nodes. From a8365a92a02c4c1c1852f56dcc359c8e65a2b9c0 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 13:59:52 -0600 Subject: [PATCH 06/12] #26045 data source tests --- internal/service/opensearch/domain_data_source_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/service/opensearch/domain_data_source_test.go b/internal/service/opensearch/domain_data_source_test.go index 9f5e8f6eb2c..93702c9a702 100644 --- a/internal/service/opensearch/domain_data_source_test.go +++ b/internal/service/opensearch/domain_data_source_test.go @@ -41,8 +41,10 @@ func TestAccOpenSearchDomainDataSource_Data_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, "cluster_config.0.zone_awareness_enabled", resourceName, "cluster_config.0.zone_awareness_enabled"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.#", resourceName, "ebs_options.#"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.ebs_enabled", resourceName, "ebs_options.0.ebs_enabled"), + resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.throughput", resourceName, "ebs_options.0.throughput"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.volume_type", resourceName, "ebs_options.0.volume_type"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.volume_size", resourceName, "ebs_options.0.volume_size"), + resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.iops", resourceName, "ebs_options.0.iops"), resource.TestCheckResourceAttrPair(datasourceName, "snapshot_options.#", resourceName, "snapshot_options.#"), resource.TestCheckResourceAttrPair(datasourceName, "snapshot_options.0.automated_snapshot_start_hour", resourceName, "snapshot_options.0.automated_snapshot_start_hour"), resource.TestCheckResourceAttrPair(datasourceName, "advanced_security_options.#", resourceName, "advanced_security_options.#"), @@ -150,7 +152,7 @@ POLICY } cluster_config { - instance_type = "t2.small.search" + instance_type = "t3.small.search" instance_count = 2 dedicated_master_enabled = false @@ -163,7 +165,9 @@ POLICY ebs_options { ebs_enabled = true - volume_type = "gp2" + iops = 3000 + throughput = 125 + volume_type = "gp3" volume_size = 20 } From 33a155d27b4b5b87aa32726709d5399c1a9ebad9 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 14:03:50 -0600 Subject: [PATCH 07/12] #26045 resource tests --- internal/service/opensearch/domain_test.go | 37 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/internal/service/opensearch/domain_test.go b/internal/service/opensearch/domain_test.go index 85a0e9624d1..f8c3863cdd8 100644 --- a/internal/service/opensearch/domain_test.go +++ b/internal/service/opensearch/domain_test.go @@ -1412,11 +1412,13 @@ func TestAccOpenSearchDomain_VolumeType_update(t *testing.T) { CheckDestroy: testAccCheckDomainDestroy, Steps: []resource.TestStep{ { - Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 24), + Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 24, 250, 3500), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(resourceName, &input), testAccCheckEBSVolumeEnabled(true, &input), testAccCheckEBSVolumeSize(24, &input), + testAccCheckEBSVolumeThroughput(250, &input), + testAccCheckEBSVolumeIops(3500, &input), ), }, { @@ -1433,11 +1435,13 @@ func TestAccOpenSearchDomain_VolumeType_update(t *testing.T) { ), }, { - Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 12), + Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 12, 125, 3000), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(resourceName, &input), testAccCheckEBSVolumeEnabled(true, &input), testAccCheckEBSVolumeSize(12, &input), + testAccCheckEBSVolumeThroughput(125, &input), + testAccCheckEBSVolumeIops(3000, &input), ), }, }}) @@ -1596,6 +1600,26 @@ func testAccCheckNumberOfSecurityGroups(numberOfSecurityGroups int, status *open } } +func testAccCheckEBSVolumeThroughput(ebsVolumeThroughput int, status *opensearchservice.DomainStatus) resource.TestCheckFunc { + return func(s *terraform.State) error { + conf := status.EBSOptions + if *conf.Throughput != int64(ebsVolumeThroughput) { + return fmt.Errorf("EBS throughput differ. Given: %d, Expected: %d", *conf.Throughput, ebsVolumeThroughput) + } + return nil + } +} + +func testAccCheckEBSVolumeIops(ebsVolumeIops int, status *opensearchservice.DomainStatus) resource.TestCheckFunc { + return func(s *terraform.State) error { + conf := status.EBSOptions + if *conf.Iops != int64(ebsVolumeIops) { + return fmt.Errorf("EBS IOPS differ. Given: %d, Expected: %d", *conf.Iops, ebsVolumeIops) + } + return nil + } +} + func testAccCheckEBSVolumeSize(ebsVolumeSize int, status *opensearchservice.DomainStatus) resource.TestCheckFunc { return func(s *terraform.State) error { conf := status.EBSOptions @@ -2158,7 +2182,7 @@ resource "aws_opensearch_domain" "test" { `, rName, instanceInt, snapshotInt) } -func testAccDomainConfig_clusterUpdateEBSVolume(rName string, volumeSize int) string { +func testAccDomainConfig_clusterUpdateEBSVolume(rName string, volumeSize int, volumeThroughput int, volumeIops int) string { return fmt.Sprintf(` resource "aws_opensearch_domain" "test" { domain_name = substr(%[1]q, 0, 28) @@ -2172,15 +2196,18 @@ resource "aws_opensearch_domain" "test" { ebs_options { ebs_enabled = true volume_size = %d + throughput = %d + volume_type = "gp3" + iops = %d } cluster_config { instance_count = 2 zone_awareness_enabled = true - instance_type = "t2.small.search" + instance_type = "t3.small.search" } } -`, rName, volumeSize) +`, rName, volumeSize, volumeThroughput, volumeIops) } func testAccDomainConfig_clusterUpdateVersion(rName, version string) string { From 37030eb8e375d85631d041a2045cda447872bfd2 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 14:04:24 -0600 Subject: [PATCH 08/12] #26045 changelog --- .changelog/26045.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changelog/26045.txt diff --git a/.changelog/26045.txt b/.changelog/26045.txt new file mode 100644 index 00000000000..ed98c3da75a --- /dev/null +++ b/.changelog/26045.txt @@ -0,0 +1,7 @@ +```release-note:enhancement +resource/aws_elasticsearch_domain: Add `throughput` attribute to the `ebs_options` configuration block +``` + +```release-note:enhancement +data-source/aws_elasticsearch_domain: Add `throughput` attribute to the `ebs_options` configuration block +``` \ No newline at end of file From b7e540977bc5cab925a617ec1b4947e597a15103 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 14:22:45 -0600 Subject: [PATCH 09/12] #26045 terrafmt --- internal/service/opensearch/domain_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/opensearch/domain_test.go b/internal/service/opensearch/domain_test.go index f8c3863cdd8..8f9532402af 100644 --- a/internal/service/opensearch/domain_test.go +++ b/internal/service/opensearch/domain_test.go @@ -2196,9 +2196,9 @@ resource "aws_opensearch_domain" "test" { ebs_options { ebs_enabled = true volume_size = %d - throughput = %d - volume_type = "gp3" - iops = %d + throughput = %d + volume_type = "gp3" + iops = %d } cluster_config { From 76bcec902974a58cbf205ee5634cd9d8caa4ca33 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 14:25:38 -0600 Subject: [PATCH 10/12] #26045 terrafmt --- internal/service/opensearch/domain_data_source_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/opensearch/domain_data_source_test.go b/internal/service/opensearch/domain_data_source_test.go index 93702c9a702..b708f6ce49d 100644 --- a/internal/service/opensearch/domain_data_source_test.go +++ b/internal/service/opensearch/domain_data_source_test.go @@ -166,7 +166,7 @@ POLICY ebs_options { ebs_enabled = true iops = 3000 - throughput = 125 + throughput = 125 volume_type = "gp3" volume_size = 20 } From 0d3070186941781d5ef8218e3755fcdf1a3a1f32 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 8 Aug 2022 14:33:35 -0600 Subject: [PATCH 11/12] #26045 typo --- website/docs/r/opensearch_domain.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/opensearch_domain.html.markdown b/website/docs/r/opensearch_domain.html.markdown index 0bed22d4e6e..f23d55bdafd 100644 --- a/website/docs/r/opensearch_domain.html.markdown +++ b/website/docs/r/opensearch_domain.html.markdown @@ -311,7 +311,7 @@ AWS documentation: [Amazon Cognito Authentication for Kibana](https://docs.aws.a * `ebs_enabled` - (Required) Whether EBS volumes are attached to data nodes in the domain. * `iops` - (Optional) Baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the GP3 and Provisioned IOPS EBS volume types. -* `throughput` - (Required if `volume_type` is set to `gp3`) Specifies the throughput (in MiB/s) of the EBS volumes attached to data nodes. Applicable only for the gp3 volume type. Valid values are between `125` and `1000` +* `throughput` - (Required if `volume_type` is set to `gp3`) Specifies the throughput (in MiB/s) of the EBS volumes attached to data nodes. Applicable only for the gp3 volume type. Valid values are between `125` and `1000`. * `volume_size` - (Required if `ebs_enabled` is set to `true`.) Size of EBS volumes attached to data nodes (in GiB). * `volume_type` - (Optional) Type of EBS volumes attached to data nodes. From eb7d69ff4ffc9bdca47aa0b1d25bba2328ee57a0 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 10 Aug 2022 14:30:08 -0400 Subject: [PATCH 12/12] Elasticsearch domain: Add 'ebs_options.throughput' as for OpenSearch domains. --- .changelog/26045.txt | 8 ++++ internal/service/elasticsearch/domain.go | 6 +++ .../elasticsearch/domain_data_source.go | 4 ++ .../elasticsearch/domain_data_source_test.go | 7 +++- internal/service/elasticsearch/domain_test.go | 37 ++++++++++++++++--- internal/service/elasticsearch/flex.go | 6 +++ .../docs/d/elasticsearch_domain.html.markdown | 1 + .../docs/r/elasticsearch_domain.html.markdown | 3 +- 8 files changed, 64 insertions(+), 8 deletions(-) diff --git a/.changelog/26045.txt b/.changelog/26045.txt index ed98c3da75a..ed9b5b66a7c 100644 --- a/.changelog/26045.txt +++ b/.changelog/26045.txt @@ -4,4 +4,12 @@ resource/aws_elasticsearch_domain: Add `throughput` attribute to the `ebs_option ```release-note:enhancement data-source/aws_elasticsearch_domain: Add `throughput` attribute to the `ebs_options` configuration block +``` + +```release-note:enhancement +resource/aws_opensearch_domain: Add `throughput` attribute to the `ebs_options` configuration block +``` + +```release-note:enhancement +data-source/aws_opensearch_domain: Add `throughput` attribute to the `ebs_options` configuration block ``` \ No newline at end of file diff --git a/internal/service/elasticsearch/domain.go b/internal/service/elasticsearch/domain.go index eaf19a8e6fd..8c2b54915df 100644 --- a/internal/service/elasticsearch/domain.go +++ b/internal/service/elasticsearch/domain.go @@ -385,6 +385,12 @@ func ResourceDomain() *schema.Resource { Type: schema.TypeInt, Optional: true, }, + "throughput": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntBetween(125, 1000), + }, "volume_size": { Type: schema.TypeInt, Optional: true, diff --git a/internal/service/elasticsearch/domain_data_source.go b/internal/service/elasticsearch/domain_data_source.go index 271150eeca0..0abcb86f019 100644 --- a/internal/service/elasticsearch/domain_data_source.go +++ b/internal/service/elasticsearch/domain_data_source.go @@ -215,6 +215,10 @@ func DataSourceDomain() *schema.Resource { Type: schema.TypeInt, Computed: true, }, + "throughput": { + Type: schema.TypeInt, + Computed: true, + }, "volume_size": { Type: schema.TypeInt, Computed: true, diff --git a/internal/service/elasticsearch/domain_data_source_test.go b/internal/service/elasticsearch/domain_data_source_test.go index 6a5aa8bbbbd..64cb9bcc768 100644 --- a/internal/service/elasticsearch/domain_data_source_test.go +++ b/internal/service/elasticsearch/domain_data_source_test.go @@ -41,6 +41,7 @@ func TestAccElasticsearchDomainDataSource_Data_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, "cluster_config.0.zone_awareness_enabled", resourceName, "cluster_config.0.zone_awareness_enabled"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.#", resourceName, "ebs_options.#"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.ebs_enabled", resourceName, "ebs_options.0.ebs_enabled"), + resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.throughput", resourceName, "ebs_options.0.throughput"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.volume_type", resourceName, "ebs_options.0.volume_type"), resource.TestCheckResourceAttrPair(datasourceName, "ebs_options.0.volume_size", resourceName, "ebs_options.0.volume_size"), resource.TestCheckResourceAttrPair(datasourceName, "snapshot_options.#", resourceName, "snapshot_options.#"), @@ -150,7 +151,7 @@ POLICY } cluster_config { - instance_type = "t2.small.elasticsearch" + instance_type = "t3.small.elasticsearch" instance_count = 2 dedicated_master_enabled = false @@ -163,7 +164,9 @@ POLICY ebs_options { ebs_enabled = true - volume_type = "gp2" + iops = 3000 + throughput = 125 + volume_type = "gp3" volume_size = 20 } diff --git a/internal/service/elasticsearch/domain_test.go b/internal/service/elasticsearch/domain_test.go index 732d9c96bc4..9a63ac4dbbf 100644 --- a/internal/service/elasticsearch/domain_test.go +++ b/internal/service/elasticsearch/domain_test.go @@ -1358,11 +1358,13 @@ func TestAccElasticsearchDomain_UpdateVolume_type(t *testing.T) { CheckDestroy: testAccCheckDomainDestroy, Steps: []resource.TestStep{ { - Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 24), + Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 24, 250, 3500), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(resourceName, &input), testAccCheckEBSVolumeEnabled(true, &input), testAccCheckEBSVolumeSize(24, &input), + testAccCheckEBSVolumeThroughput(250, &input), + testAccCheckEBSVolumeIops(3500, &input), ), }, { @@ -1379,11 +1381,13 @@ func TestAccElasticsearchDomain_UpdateVolume_type(t *testing.T) { ), }, { - Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 12), + Config: testAccDomainConfig_clusterUpdateEBSVolume(rName, 12, 125, 3000), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(resourceName, &input), testAccCheckEBSVolumeEnabled(true, &input), testAccCheckEBSVolumeSize(12, &input), + testAccCheckEBSVolumeThroughput(125, &input), + testAccCheckEBSVolumeIops(3000, &input), ), }, }}) @@ -1542,6 +1546,26 @@ func testAccCheckNumberOfSecurityGroups(numberOfSecurityGroups int, status *elas } } +func testAccCheckEBSVolumeThroughput(ebsVolumeThroughput int, status *elasticsearch.ElasticsearchDomainStatus) resource.TestCheckFunc { + return func(s *terraform.State) error { + conf := status.EBSOptions + if *conf.Throughput != int64(ebsVolumeThroughput) { + return fmt.Errorf("EBS throughput differ. Given: %d, Expected: %d", *conf.Throughput, ebsVolumeThroughput) + } + return nil + } +} + +func testAccCheckEBSVolumeIops(ebsVolumeIops int, status *elasticsearch.ElasticsearchDomainStatus) resource.TestCheckFunc { + return func(s *terraform.State) error { + conf := status.EBSOptions + if *conf.Iops != int64(ebsVolumeIops) { + return fmt.Errorf("EBS IOPS differ. Given: %d, Expected: %d", *conf.Iops, ebsVolumeIops) + } + return nil + } +} + func testAccCheckEBSVolumeSize(ebsVolumeSize int, status *elasticsearch.ElasticsearchDomainStatus) resource.TestCheckFunc { return func(s *terraform.State) error { conf := status.EBSOptions @@ -2048,7 +2072,7 @@ resource "aws_elasticsearch_domain" "test" { `, rName, instanceInt, snapshotInt) } -func testAccDomainConfig_clusterUpdateEBSVolume(rName string, volumeSize int) string { +func testAccDomainConfig_clusterUpdateEBSVolume(rName string, volumeSize int, volumeThroughput int, volumeIops int) string { return fmt.Sprintf(` resource "aws_elasticsearch_domain" "test" { domain_name = substr(%[1]q, 0, 28) @@ -2062,15 +2086,18 @@ resource "aws_elasticsearch_domain" "test" { ebs_options { ebs_enabled = true volume_size = %d + throughput = %d + volume_type = "gp3" + iops = %d } cluster_config { instance_count = 2 zone_awareness_enabled = true - instance_type = "t2.small.elasticsearch" + instance_type = "t3.small.elasticsearch" } } -`, rName, volumeSize) +`, rName, volumeSize, volumeThroughput, volumeIops) } func testAccDomainConfig_clusterUpdateVersion(rName, version string) string { diff --git a/internal/service/elasticsearch/flex.go b/internal/service/elasticsearch/flex.go index bd22a071a11..b210dd21475 100644 --- a/internal/service/elasticsearch/flex.go +++ b/internal/service/elasticsearch/flex.go @@ -80,6 +80,9 @@ func expandEBSOptions(m map[string]interface{}) *elasticsearch.EBSOptions { if v, ok := m["iops"]; ok && v.(int) > 0 { options.Iops = aws.Int64(int64(v.(int))) } + if v, ok := m["throughput"]; ok && v.(int) > 0 { + options.Throughput = aws.Int64(int64(v.(int))) + } if v, ok := m["volume_size"]; ok && v.(int) > 0 { options.VolumeSize = aws.Int64(int64(v.(int))) } @@ -165,6 +168,9 @@ func flattenEBSOptions(o *elasticsearch.EBSOptions) []map[string]interface{} { if o.Iops != nil { m["iops"] = aws.Int64Value(o.Iops) } + if o.Throughput != nil { + m["throughput"] = aws.Int64Value(o.Throughput) + } if o.VolumeSize != nil { m["volume_size"] = aws.Int64Value(o.VolumeSize) } diff --git a/website/docs/d/elasticsearch_domain.html.markdown b/website/docs/d/elasticsearch_domain.html.markdown index a0da4a6f88a..81c6133332a 100644 --- a/website/docs/d/elasticsearch_domain.html.markdown +++ b/website/docs/d/elasticsearch_domain.html.markdown @@ -68,6 +68,7 @@ The following attributes are exported: * `domain_id` – Unique identifier for the domain. * `ebs_options` - EBS Options for the instances in the domain. * `ebs_enabled` - Whether EBS volumes are attached to data nodes in the domain. + * `throughput` - The throughput (in MiB/s) of the EBS volumes attached to data nodes. * `volume_type` - The type of EBS volumes attached to data nodes. * `volume_size` - The size of EBS volumes attached to data nodes (in GB). * `iops` - The baseline input/output (I/O) performance of EBS volumes attached to data nodes. diff --git a/website/docs/r/elasticsearch_domain.html.markdown b/website/docs/r/elasticsearch_domain.html.markdown index f0c436eca5b..3159adaa35d 100644 --- a/website/docs/r/elasticsearch_domain.html.markdown +++ b/website/docs/r/elasticsearch_domain.html.markdown @@ -293,7 +293,8 @@ AWS documentation: [Amazon Cognito Authentication for Kibana](https://docs.aws.a ### ebs_options * `ebs_enabled` - (Required) Whether EBS volumes are attached to data nodes in the domain. -* `iops` - (Optional) Baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the Provisioned IOPS EBS volume type. +* `iops` - (Optional) Baseline input/output (I/O) performance of EBS volumes attached to data nodes. Applicable only for the GP3 and Provisioned IOPS EBS volume types. +* `throughput` - (Required if `volume_type` is set to `gp3`) Specifies the throughput (in MiB/s) of the EBS volumes attached to data nodes. Applicable only for the gp3 volume type. Valid values are between `125` and `1000`. * `volume_size` - (Required if `ebs_enabled` is set to `true`.) Size of EBS volumes attached to data nodes (in GiB). * `volume_type` - (Optional) Type of EBS volumes attached to data nodes.