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_opensearch_domain: Omit IOPS/Throughput when not supported #28862

Merged
merged 3 commits into from
Jan 13, 2023

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Jan 12, 2023

Description

This fix prevents the Throughput and Iops EBS options from being included in the input struct when the specified volume type does not support them.

Specifically, this can happen when a configuration uses a gp3 volume type without specifying iops or throughput, then the volume type changes to a type that doesn't support these arguments. On the first apply, the default values set by AWS are written to state. On the subsequent apply these should be omitted from the UpdateDomain request input to avoid a ValidationException.

Relations

Closes #27467

References

https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/opensearch@v1.12.0/types#EBSOptions

Output from Acceptance Testing

$ make testacc PKG=opensearch TESTS=TestAccOpenSearchDomain_VolumeType
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/opensearch/... -v -count 1 -parallel 20 -run='TestAccOpenSearchDomain_VolumeType'  -timeout 180m
=== RUN   TestAccOpenSearchDomain_VolumeType_update
=== PAUSE TestAccOpenSearchDomain_VolumeType_update
=== RUN   TestAccOpenSearchDomain_VolumeType_GP3ToGP2
=== PAUSE TestAccOpenSearchDomain_VolumeType_GP3ToGP2
=== RUN   TestAccOpenSearchDomain_VolumeType_missing
=== PAUSE TestAccOpenSearchDomain_VolumeType_missing
=== CONT  TestAccOpenSearchDomain_VolumeType_update
=== CONT  TestAccOpenSearchDomain_VolumeType_missing
=== CONT  TestAccOpenSearchDomain_VolumeType_GP3ToGP2
--- PASS: TestAccOpenSearchDomain_VolumeType_missing (1195.95s)
--- PASS: TestAccOpenSearchDomain_VolumeType_GP3ToGP2 (3440.65s)
--- PASS: TestAccOpenSearchDomain_VolumeType_update (4052.78s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/opensearch 4055.888s
$ go test -v ./internal/service/opensearch/... -run ^TestEBS
=== RUN   TestEBSVolumeTypePermitsIopsInput
=== PAUSE TestEBSVolumeTypePermitsIopsInput
=== RUN   TestEBSVolumeTypePermitsThroughputInput
=== PAUSE TestEBSVolumeTypePermitsThroughputInput
=== CONT  TestEBSVolumeTypePermitsIopsInput
=== RUN   TestEBSVolumeTypePermitsIopsInput/empty
=== PAUSE TestEBSVolumeTypePermitsIopsInput/empty
=== RUN   TestEBSVolumeTypePermitsIopsInput/gp2
=== PAUSE TestEBSVolumeTypePermitsIopsInput/gp2
=== RUN   TestEBSVolumeTypePermitsIopsInput/gp3
=== PAUSE TestEBSVolumeTypePermitsIopsInput/gp3
=== RUN   TestEBSVolumeTypePermitsIopsInput/io1
=== PAUSE TestEBSVolumeTypePermitsIopsInput/io1
=== CONT  TestEBSVolumeTypePermitsThroughputInput
=== RUN   TestEBSVolumeTypePermitsIopsInput/standard
=== PAUSE TestEBSVolumeTypePermitsIopsInput/standard
=== RUN   TestEBSVolumeTypePermitsThroughputInput/empty
=== CONT  TestEBSVolumeTypePermitsIopsInput/empty
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/empty
=== CONT  TestEBSVolumeTypePermitsIopsInput/gp3
=== CONT  TestEBSVolumeTypePermitsIopsInput/gp2
=== CONT  TestEBSVolumeTypePermitsIopsInput/io1
=== CONT  TestEBSVolumeTypePermitsIopsInput/standard
--- PASS: TestEBSVolumeTypePermitsIopsInput (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/empty (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/gp3 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/gp2 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/io1 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/standard (0.00s)
=== RUN   TestEBSVolumeTypePermitsThroughputInput/gp2
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/gp2
=== RUN   TestEBSVolumeTypePermitsThroughputInput/gp3
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/gp3
=== RUN   TestEBSVolumeTypePermitsThroughputInput/io1
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/io1
=== RUN   TestEBSVolumeTypePermitsThroughputInput/standard
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/standard
=== CONT  TestEBSVolumeTypePermitsThroughputInput/empty
=== CONT  TestEBSVolumeTypePermitsThroughputInput/standard
=== CONT  TestEBSVolumeTypePermitsThroughputInput/io1
=== CONT  TestEBSVolumeTypePermitsThroughputInput/gp2
=== CONT  TestEBSVolumeTypePermitsThroughputInput/gp3
--- PASS: TestEBSVolumeTypePermitsThroughputInput (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/empty (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/standard (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/io1 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/gp2 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/gp3 (0.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/opensearch 2.908s

Output of the new acceptance test prior to the expander changes that confirms the behavior:

$ make testacc PKG=opensearch TESTS=TestAccOpenSearchDomain_VolumeType_gp3ToStandard
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/opensearch/... -v -count 1 -parallel 20 -run='TestAccOpenSearchDomain_VolumeType_gp3ToStandard'  -timeout 180m
=== RUN   TestAccOpenSearchDomain_VolumeType_gp3ToStandard
=== PAUSE TestAccOpenSearchDomain_VolumeType_gp3ToStandard
=== CONT  TestAccOpenSearchDomain_VolumeType_gp3ToStandard
    domain_test.go:1509: Step 3/3 error: Error running apply: exit status 1

        Error: ValidationException: Throughput is only valid when volume type is GP3.

          with aws_opensearch_domain.test,
          on terraform_plugin_test.tf line 2, in resource "aws_opensearch_domain" "test":
           2: resource "aws_opensearch_domain" "test" {

--- FAIL: TestAccOpenSearchDomain_VolumeType_gp3ToStandard (1387.59s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/opensearch 1390.825s
FAIL
make: *** [testacc] Error 1

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added service/opensearch Issues and PRs that pertain to the opensearch service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/L Managed by automation to categorize the size of a PR. labels Jan 12, 2023
@jar-b jar-b marked this pull request as ready for review January 13, 2023 01:09
@YakDriver YakDriver self-assigned this Jan 13, 2023
Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, couple small things. 🎉

% make testacc PKG=opensearch TESTS=TestAccOpenSearchDomain_VolumeType 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/opensearch/... -v -count 1 -parallel 20 -run='TestAccOpenSearchDomain_VolumeType'  -timeout 180m
=== RUN   TestAccOpenSearchDomain_VolumeType_update
=== PAUSE TestAccOpenSearchDomain_VolumeType_update
=== RUN   TestAccOpenSearchDomain_VolumeType_GP3ToGP2
=== PAUSE TestAccOpenSearchDomain_VolumeType_GP3ToGP2
=== RUN   TestAccOpenSearchDomain_VolumeType_missing
=== PAUSE TestAccOpenSearchDomain_VolumeType_missing
=== CONT  TestAccOpenSearchDomain_VolumeType_update
=== CONT  TestAccOpenSearchDomain_VolumeType_missing
=== CONT  TestAccOpenSearchDomain_VolumeType_GP3ToGP2
--- PASS: TestAccOpenSearchDomain_VolumeType_missing (1197.13s)
--- PASS: TestAccOpenSearchDomain_VolumeType_GP3ToGP2 (3983.84s)
--- PASS: TestAccOpenSearchDomain_VolumeType_update (5333.95s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/opensearch	5335.486s
% go test -v ./internal/service/opensearch/... -run ^TestEBS
=== RUN   TestEBSVolumeTypePermitsIopsInput
=== PAUSE TestEBSVolumeTypePermitsIopsInput
=== RUN   TestEBSVolumeTypePermitsThroughputInput
=== PAUSE TestEBSVolumeTypePermitsThroughputInput
=== CONT  TestEBSVolumeTypePermitsIopsInput
=== RUN   TestEBSVolumeTypePermitsIopsInput/empty
=== PAUSE TestEBSVolumeTypePermitsIopsInput/empty
=== RUN   TestEBSVolumeTypePermitsIopsInput/gp2
=== PAUSE TestEBSVolumeTypePermitsIopsInput/gp2
=== CONT  TestEBSVolumeTypePermitsThroughputInput
=== RUN   TestEBSVolumeTypePermitsIopsInput/gp3
=== PAUSE TestEBSVolumeTypePermitsIopsInput/gp3
=== RUN   TestEBSVolumeTypePermitsThroughputInput/empty
=== RUN   TestEBSVolumeTypePermitsIopsInput/io1
=== PAUSE TestEBSVolumeTypePermitsIopsInput/io1
=== RUN   TestEBSVolumeTypePermitsIopsInput/standard
=== PAUSE TestEBSVolumeTypePermitsIopsInput/standard
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/empty
=== CONT  TestEBSVolumeTypePermitsIopsInput/empty
=== RUN   TestEBSVolumeTypePermitsThroughputInput/gp2
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/gp2
=== CONT  TestEBSVolumeTypePermitsIopsInput/standard
=== RUN   TestEBSVolumeTypePermitsThroughputInput/gp3
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/gp3
=== CONT  TestEBSVolumeTypePermitsIopsInput/io1
=== CONT  TestEBSVolumeTypePermitsIopsInput/gp3
=== RUN   TestEBSVolumeTypePermitsThroughputInput/io1
=== CONT  TestEBSVolumeTypePermitsIopsInput/gp2
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/io1
--- PASS: TestEBSVolumeTypePermitsIopsInput (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/empty (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/standard (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/io1 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/gp3 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsIopsInput/gp2 (0.00s)
=== RUN   TestEBSVolumeTypePermitsThroughputInput/standard
=== PAUSE TestEBSVolumeTypePermitsThroughputInput/standard
=== CONT  TestEBSVolumeTypePermitsThroughputInput/empty
=== CONT  TestEBSVolumeTypePermitsThroughputInput/standard
=== CONT  TestEBSVolumeTypePermitsThroughputInput/gp2
=== CONT  TestEBSVolumeTypePermitsThroughputInput/io1
=== CONT  TestEBSVolumeTypePermitsThroughputInput/gp3
--- PASS: TestEBSVolumeTypePermitsThroughputInput (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/empty (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/standard (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/gp2 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/io1 (0.00s)
    --- PASS: TestEBSVolumeTypePermitsThroughputInput/gp3 (0.00s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/opensearch	1.639s

internal/service/opensearch/domain_test.go Outdated Show resolved Hide resolved
internal/service/opensearch/domain_test.go Outdated Show resolved Hide resolved
internal/service/opensearch/domain_test.go Outdated Show resolved Hide resolved
Apply suggestions from code review

Co-authored-by: Dirk Avery <31492422+YakDriver@users.noreply.github.com>
@jar-b jar-b merged commit 6ce9990 into main Jan 13, 2023
@jar-b jar-b deleted the b-opensearch-ebs-options branch January 13, 2023 20:56
@github-actions github-actions bot added this to the v4.51.0 milestone Jan 13, 2023
github-actions bot pushed a commit that referenced this pull request Jan 13, 2023
@github-actions
Copy link

This functionality has been released in v4.51.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/opensearch Issues and PRs that pertain to the opensearch service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_opensearch_domain ebs_options throughput attribute populated for non-gp3 volume types? [Bug]:
2 participants