From c6cf895d99c2e86efcf4a34611169bef35b1276b Mon Sep 17 00:00:00 2001 From: Elena Xin <39109137+sinbai@users.noreply.github.com> Date: Wed, 12 Jun 2024 05:50:47 +0800 Subject: [PATCH] `azurerm_lb_backend_address_pool_address` - when using this resource, values are no longer reset on `azurerm_lb_backend_address_pool` (#26264) --- .../backend_address_pool_address_resource.go | 17 +++++------------ ...ackend_address_pool_address_resource_test.go | 9 +++------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/internal/services/loadbalancer/backend_address_pool_address_resource.go b/internal/services/loadbalancer/backend_address_pool_address_resource.go index fe7a0b5946bb..feb2e824c7c4 100644 --- a/internal/services/loadbalancer/backend_address_pool_address_resource.go +++ b/internal/services/loadbalancer/backend_address_pool_address_resource.go @@ -211,13 +211,10 @@ func (r BackendAddressPoolAddressResource) Create() sdk.ResourceFunc { }) } - backendAddressPool := loadbalancers.BackendAddressPool{ - Properties: &loadbalancers.BackendAddressPoolPropertiesFormat{ - LoadBalancerBackendAddresses: &addresses, - }, - } + pool.Model.Properties.LoadBalancerBackendAddresses = &addresses + metadata.Logger.Infof("adding %s..", id) - err = lbClient.LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx, *poolId, backendAddressPool) + err = lbClient.LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx, *poolId, *pool.Model) if err != nil { return fmt.Errorf("updating %s: %+v", id, err) } @@ -478,11 +475,7 @@ func (r BackendAddressPoolAddressResource) Update() sdk.ResourceFunc { } } - backendAddressPool := loadbalancers.BackendAddressPool{ - Properties: &loadbalancers.BackendAddressPoolPropertiesFormat{ - LoadBalancerBackendAddresses: &addresses, - }, - } + pool.Model.Properties.LoadBalancerBackendAddresses = &addresses timeout, _ := ctx.Deadline() lbStatus := &pluginsdk.StateChangeConf{ @@ -499,7 +492,7 @@ func (r BackendAddressPoolAddressResource) Update() sdk.ResourceFunc { return fmt.Errorf("waiting for parent resource loadbalancer status to be ready error: %+v", err) } - err = lbClient.LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx, poolId, backendAddressPool) + err = lbClient.LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx, poolId, *pool.Model) if err != nil { return fmt.Errorf("updating %s: %+v", *id, err) } diff --git a/internal/services/loadbalancer/backend_address_pool_address_resource_test.go b/internal/services/loadbalancer/backend_address_pool_address_resource_test.go index fcc8c765ae19..87dabb3c447d 100644 --- a/internal/services/loadbalancer/backend_address_pool_address_resource_test.go +++ b/internal/services/loadbalancer/backend_address_pool_address_resource_test.go @@ -190,12 +190,9 @@ func (BackendAddressPoolAddressResourceTests) Destroy(ctx context.Context, clien } } - backendAddressPool := loadbalancers.BackendAddressPool{ - Properties: &loadbalancers.BackendAddressPoolPropertiesFormat{ - LoadBalancerBackendAddresses: &newAddresses, - }, - } - err = client.LoadBalancers.LoadBalancersClient.LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx, poolId, backendAddressPool) + pool.Model.Properties.LoadBalancerBackendAddresses = &newAddresses + + err = client.LoadBalancers.LoadBalancersClient.LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx, poolId, *pool.Model) if err != nil { return nil, fmt.Errorf("updating %s: %+v", *id, err) }