@@ -295,6 +295,10 @@ func namedLocationResourceDelete(ctx context.Context, d *pluginsdk.ResourceData,
295295
296296 return tf .ErrorDiagF (err , "updating %s prior to deletion" , id )
297297 }
298+
299+ if err = consistency .WaitForUpdate (ctx , ipNamedLocationTrustedDeleteWait (client , id )); err != nil {
300+ return tf .ErrorDiagF (err , "waiting for removal of trusted status on %s" , id )
301+ }
298302 }
299303
300304 resp , err := client .DeleteConditionalAccessNamedLocation (ctx , * id , conditionalaccessnamedlocation .DefaultDeleteConditionalAccessNamedLocationOperationOptions ())
@@ -358,6 +362,30 @@ func ipNamedLocationWait(client *conditionalaccessnamedlocation.ConditionalAcces
358362 }
359363}
360364
365+ func ipNamedLocationTrustedDeleteWait (client * conditionalaccessnamedlocation.ConditionalAccessNamedLocationClient , id * stable.IdentityConditionalAccessNamedLocationId ) consistency.ChangeFunc {
366+ return func (ctx context.Context ) (* bool , error ) {
367+ resp , err := client .GetConditionalAccessNamedLocation (ctx , * id , conditionalaccessnamedlocation .DefaultGetConditionalAccessNamedLocationOperationOptions ())
368+ if err != nil {
369+ return nil , err
370+ }
371+
372+ if resp .Model == nil {
373+ return nil , errors .New ("returned model was nil" )
374+ }
375+
376+ namedLocation , ok := resp .Model .(stable.IPNamedLocation )
377+ if ! ok {
378+ return nil , errors .New ("returned model was not an IPNamedLocation" )
379+ }
380+
381+ if pointer .From (namedLocation .IsTrusted ) {
382+ return pointer .To (false ), nil
383+ }
384+
385+ return pointer .To (true ), nil
386+ }
387+ }
388+
361389func countryNamedLocationWait (client * conditionalaccessnamedlocation.ConditionalAccessNamedLocationClient , id * stable.IdentityConditionalAccessNamedLocationId , v interface {}) consistency.ChangeFunc {
362390 return func (ctx context.Context ) (* bool , error ) {
363391 resp , err := client .GetConditionalAccessNamedLocation (ctx , * id , conditionalaccessnamedlocation .DefaultGetConditionalAccessNamedLocationOperationOptions ())
0 commit comments