Skip to content

Commit

Permalink
Merge pull request hashicorp#32716 from taktakpeops/fix/opensearchdom…
Browse files Browse the repository at this point in the history
…ain-offpeakwindow

fix: allow setting offpeakwindow at 00:00
  • Loading branch information
ewbankkit committed Jul 27, 2023
2 parents 00e4286 + c888d0c commit 1adfde3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/32716.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_opensearch_domain: Correctly handle `off_peak_window_options.off_peak_window.window_start_time` value of `00:00`
```
4 changes: 2 additions & 2 deletions internal/service/opensearch/domain_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ func expandWindowStartTime(tfMap map[string]interface{}) *opensearchservice.Wind

apiObject := &opensearchservice.WindowStartTime{}

if v, ok := tfMap["hours"].(int); ok && v != 0 {
if v, ok := tfMap["hours"].(int); ok {
apiObject.Hours = aws.Int64(int64(v))
}

if v, ok := tfMap["minutes"].(int); ok && v != 0 {
if v, ok := tfMap["minutes"].(int); ok {
apiObject.Minutes = aws.Int64(int64(v))
}

Expand Down
12 changes: 12 additions & 0 deletions internal/service/opensearch/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,18 @@ func TestAccOpenSearchDomain_offPeakWindowOptions(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "off_peak_window_options.0.off_peak_window.0.window_start_time.0.minutes", "15"),
),
},
{
Config: testAccDomainConfig_offPeakWindowOptions(rName, 0, 0),
Check: resource.ComposeTestCheckFunc(
testAccCheckDomainExists(ctx, resourceName, &domain),
resource.TestCheckResourceAttr(resourceName, "off_peak_window_options.#", "1"),
resource.TestCheckResourceAttr(resourceName, "off_peak_window_options.0.enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "off_peak_window_options.0.off_peak_window.#", "1"),
resource.TestCheckResourceAttr(resourceName, "off_peak_window_options.0.off_peak_window.0.window_start_time.#", "1"),
resource.TestCheckResourceAttr(resourceName, "off_peak_window_options.0.off_peak_window.0.window_start_time.0.hours", "0"),
resource.TestCheckResourceAttr(resourceName, "off_peak_window_options.0.off_peak_window.0.window_start_time.0.minutes", "0"),
),
},
},
})
}
Expand Down

0 comments on commit 1adfde3

Please sign in to comment.