@@ -3,8 +3,10 @@ package provider
33import (
44 "context"
55 "fmt"
6+ "net/http"
67 "strings"
78
9+ "github.com/hashicorp/terraform-plugin-log/tflog"
810 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
911 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1012 neon "github.com/kislerdm/neon-sdk-go"
@@ -115,11 +117,29 @@ func resourceVPCEndpointRestrictionCreateRetry(ctx context.Context, d *schema.Re
115117}
116118
117119func resourceVPCEndpointRestrictionReadRetry (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
118- return projectReadiness .Retry (resourceVPCEndpointRestrictionRead , ctx , d , meta )
120+ return projectReadiness .RetryWithFallback (resourceVPCEndpointRestrictionRead , ctx , d , meta , map [int ]FallbackFn {
121+ http .StatusNotFound : func (ctx context.Context , d * schema.ResourceData , meta interface {}) error {
122+ tflog .Debug (ctx , "VPC endpoint's restriction not found, removing from state" ,
123+ map [string ]interface {}{
124+ "project_id" : d .Get ("project_id" ),
125+ "vpc_endpoint_id" : d .Get ("vpc_endpoint_id" ),
126+ })
127+ d .SetId ("" )
128+ return nil
129+ }})
119130}
120131
121132func resourceVPCEndpointRestrictionDeleteRetry (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
122- return projectReadiness .Retry (resourceVPCEndpointRestrictionDelete , ctx , d , meta )
133+ return projectReadiness .RetryWithFallback (resourceVPCEndpointRestrictionDelete , ctx , d , meta , map [int ]FallbackFn {
134+ http .StatusNotFound : func (ctx context.Context , d * schema.ResourceData , meta interface {}) error {
135+ d .SetId ("" )
136+ return nil
137+ },
138+ http .StatusUnprocessableEntity : func (ctx context.Context , d * schema.ResourceData , meta interface {}) error {
139+ d .SetId ("" )
140+ return nil
141+ },
142+ })
123143}
124144
125145func resourceVPCEndpointRestrictionImport (ctx context.Context , d * schema.ResourceData , meta interface {}) ([]* schema.ResourceData , error ) {
0 commit comments