Skip to content

Commit 96ec3cc

Browse files
committed
fix: Read enable_default_user from config, not state
1 parent dd9c951 commit 96ec3cc

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

provider/resource_rediscloud_active_active_database.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,12 @@ func resourceRedisCloudActiveActiveDatabaseUpdate(ctx context.Context, d *schema
878878
log.Printf("[DEBUG] Update: Region %s - dbRegion map contains: %+v", regionName, dbRegion)
879879

880880
if explicitlySet {
881-
// User explicitly set it in config - send the value
882-
if val, exists := dbRegion["enable_default_user"]; exists && val != nil {
883-
regionProps.EnableDefaultUser = redis.Bool(val.(bool))
881+
// User explicitly set it in config - read value directly from config
882+
if val, found := getEnableDefaultUserValueFromConfig(d, regionName); found {
883+
regionProps.EnableDefaultUser = redis.Bool(val)
884884
log.Printf("[DEBUG] Update: Region %s - Sending enable_default_user=%v to API (explicitly set in config)", regionName, val)
885885
} else {
886-
log.Printf("[DEBUG] Update: Region %s - Field marked as explicit but not found in dbRegion map (exists=%v, val=%v)", regionName, exists, val)
886+
log.Printf("[DEBUG] Update: Region %s - Field marked as explicit but not found in config", regionName)
887887
}
888888
} else {
889889
// Not explicitly set - send global value to clear any API override
@@ -1225,6 +1225,28 @@ func isEnableDefaultUserExplicitlySetInConfig(d *schema.ResourceData, regionName
12251225
return found
12261226
}
12271227

1228+
// getEnableDefaultUserValueFromConfig gets the actual bool value of enable_default_user
1229+
// from the config for a given region. Returns (value, found).
1230+
func getEnableDefaultUserValueFromConfig(d *schema.ResourceData, regionName string) (bool, bool) {
1231+
rawConfig := d.GetRawConfig()
1232+
if rawConfig.IsNull() || !rawConfig.IsKnown() {
1233+
log.Printf("[DEBUG] getEnableDefaultUserValueFromConfig: GetRawConfig is null/unknown for region %s", regionName)
1234+
return false, false
1235+
}
1236+
1237+
log.Printf("[DEBUG] getEnableDefaultUserValueFromConfig: Reading value for region %s", regionName)
1238+
1239+
value, found := findRegionFieldInCtyValue(rawConfig, regionName, "enable_default_user")
1240+
if !found {
1241+
log.Printf("[DEBUG] getEnableDefaultUserValueFromConfig: Field not found for region %s", regionName)
1242+
return false, false
1243+
}
1244+
1245+
boolValue := value.True()
1246+
log.Printf("[DEBUG] getEnableDefaultUserValueFromConfig: Found value=%v for region %s", boolValue, regionName)
1247+
return boolValue, true
1248+
}
1249+
12281250
// isEnableDefaultUserInActualPersistedState checks if enable_default_user exists in the
12291251
// actual persisted state file (not the materialized state) for a given region using GetRawState.
12301252
// Returns true only if the field exists and is not null in the state file.

0 commit comments

Comments
 (0)