diff --git a/docs/resources/breakglassaccess.md b/docs/resources/breakglassaccess.md index cdc4f9fa..9a86518b 100644 --- a/docs/resources/breakglassaccess.md +++ b/docs/resources/breakglassaccess.md @@ -89,7 +89,11 @@ resource "rafay_breakglassaccess" "test_user" { - `name` (String) Group Name which access will be added ***Optional*** -- `start_time` (String) Time from when user access will be active +- `start_time` (String) Time from when user access will be active, if not provided it will be initialised with current time. If skipped then use lifecycle,ignore_changes to avoid changes in this field + +***Optional*** +- `timezone` (String) Timezone for the start_time + diff --git a/examples/resources/rafay_break_glass_access/resource.tf b/examples/resources/rafay_break_glass_access/resource.tf index aa404125..2b7342a8 100644 --- a/examples/resources/rafay_break_glass_access/resource.tf +++ b/examples/resources/rafay_break_glass_access/resource.tf @@ -6,14 +6,21 @@ resource "rafay_breakglassaccess" "test_user" { groups { group_expiry { expiry = 7 - name = "grp3" + name = "grp-2" + timezone = "America/Los_Angeles" } group_expiry { expiry = 8 - name = "grp1" + name = "grp-1" start_time = "2024-09-20T08:00:00Z" } user_type = "local" } } + + lifecycle { + ignore_changes = [ + spec[0].groups[0].group_expiry[0].start_time + ] + } } diff --git a/rafay/resource_breakglassaccess.go b/rafay/resource_breakglassaccess.go index 17e3797b..a81147c4 100644 --- a/rafay/resource_breakglassaccess.go +++ b/rafay/resource_breakglassaccess.go @@ -271,8 +271,12 @@ func expandGroupExpiry(p []interface{}) []*systempb.GroupExpiryDetails { expiryMap := expiry.(map[string]interface{}) ge := &systempb.GroupExpiryDetails{} - if v, ok := expiryMap["expiry"].(int); ok { - ge.Expiry = float32(v) + if v, ok := expiryMap["expiry"].(float64); ok { + ge.Expiry = v + } + + if v, ok := expiryMap["timezone"].(string); ok && len(v) > 0 { + ge.Timezone = v } if v, ok := expiryMap["name"].(string); ok && len(v) > 0 { @@ -359,11 +363,14 @@ func flattenGroupExpiry(groupExpiries []*systempb.GroupExpiryDetails) []interfac for i, expiry := range groupExpiries { expiryMap := map[string]interface{}{} - expiryMap["expiry"] = int(expiry.Expiry) + expiryMap["expiry"] = expiry.Expiry if len(expiry.Name) > 0 { expiryMap["name"] = expiry.Name } + if len(expiry.Timezone) > 0 { + expiryMap["timezone"] = expiry.Timezone + } expiryMap["start_time"] = expiry.StartTime