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

aws_elasticsearch_domain add throughput attr 26045 #26175

Merged
Merged
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
15 changes: 15 additions & 0 deletions .changelog/26045.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```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
```

```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
```
6 changes: 6 additions & 0 deletions internal/service/elasticsearch/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions internal/service/elasticsearch/domain_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions internal/service/elasticsearch/domain_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.#"),
Expand Down Expand Up @@ -150,7 +151,7 @@ POLICY
}

cluster_config {
instance_type = "t2.small.elasticsearch"
instance_type = "t3.small.elasticsearch"
instance_count = 2
dedicated_master_enabled = false

Expand All @@ -163,7 +164,9 @@ POLICY

ebs_options {
ebs_enabled = true
volume_type = "gp2"
iops = 3000
throughput = 125
volume_type = "gp3"
volume_size = 20
}

Expand Down
37 changes: 32 additions & 5 deletions internal/service/elasticsearch/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
},
{
Expand All @@ -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),
),
},
}})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions internal/service/elasticsearch/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 6 additions & 0 deletions internal/service/opensearch/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions internal/service/opensearch/domain_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions internal/service/opensearch/domain_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.#"),
Expand Down Expand Up @@ -150,7 +152,7 @@ POLICY
}

cluster_config {
instance_type = "t2.small.search"
instance_type = "t3.small.search"
instance_count = 2
dedicated_master_enabled = false

Expand All @@ -163,7 +165,9 @@ POLICY

ebs_options {
ebs_enabled = true
volume_type = "gp2"
iops = 3000
throughput = 125
volume_type = "gp3"
volume_size = 20
}

Expand Down
37 changes: 32 additions & 5 deletions internal/service/opensearch/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
},
{
Expand All @@ -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),
),
},
}})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions internal/service/opensearch/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/elasticsearch_domain.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/opensearch_domain.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/elasticsearch_domain.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/opensearch_domain.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,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.

Expand Down