Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/robfig/cron/v3 v3.0.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221128132248-9a4e57dd2f3d
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221212155715-1af141c8883f
github.com/stretchr/testify v1.8.1
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221128132248-9a4e57dd2f3d h1:UHsrc5So54Z3xDPKvnODyod2FMcX0XpvZvEgeRTghAU=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221128132248-9a4e57dd2f3d/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221212155715-1af141c8883f h1:3wdSpuBw2nlULXpYgNsh2uii60adEuWdqP5QXHw5/m0=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10.0.20221212155715-1af141c8883f/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
Expand Down
13 changes: 13 additions & 0 deletions scaleway/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,3 +808,16 @@ func validateMapKeyLowerCase() schema.SchemaValidateDiagFunc {
return nil
}
}

func retryOnTransientStateError[T any, U any](action func() (T, error), waiter func() (U, error)) (T, error) { //nolint:ireturn
t, err := action()
var transientStateError *scw.TransientStateError
if errors.As(err, &transientStateError) {
_, err := waiter()
if err != nil {
return t, err
}
return retryOnTransientStateError(action, waiter)
}
return t, err
}
8 changes: 7 additions & 1 deletion scaleway/resource_vpc_gateway_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down Expand Up @@ -127,7 +128,12 @@ func resourceScalewayVPCGatewayNetworkCreate(ctx context.Context, d *schema.Reso
req.DHCPID = &dhcpZoned.ID
}

gatewayNetwork, err := vpcgwAPI.CreateGatewayNetwork(req, scw.WithContext(ctx))
gatewayNetwork, err := retryOnTransientStateError(func() (*vpcgw.GatewayNetwork, error) {
return vpcgwAPI.CreateGatewayNetwork(req, scw.WithContext(ctx))
}, func() (*vpcgw.Gateway, error) {
tflog.Warn(ctx, "Public gateway is in transient state after waiting, retrying...")
return waitForVPCPublicGateway(ctx, vpcgwAPI, zone, gatewayID, d.Timeout(schema.TimeoutCreate))
})
if err != nil {
return diag.FromErr(err)
}
Expand Down