@@ -4,13 +4,15 @@ import (
44 "context"
55 _ "time"
66
7+ "github.com/hashicorp/go-cty/cty"
78 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
89 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
910 s2svpn "github.com/scaleway/scaleway-sdk-go/api/s2s_vpn/v1alpha1"
1011 "github.com/scaleway/scaleway-sdk-go/scw"
1112 "github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1213 "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
1314 "github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
15+ "github.com/scaleway/terraform-provider-scaleway/v2/internal/meta"
1416 "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/account"
1517 "github.com/scaleway/terraform-provider-scaleway/v2/internal/types"
1618)
@@ -115,7 +117,7 @@ func vpnGatewaySchema() map[string]*schema.Schema {
115117 Computed : true ,
116118 Description : "The date and time of the last update of the VPN gateway" ,
117119 },
118- "zone" : zonal .OptionalSchema (),
120+ "zone" : zonal .Schema (),
119121 "region" : regional .Schema (),
120122 "project_id" : account .ProjectIDSchema (),
121123 "organization_id" : {
@@ -132,7 +134,12 @@ func ResourceVPNGatewayCreate(ctx context.Context, d *schema.ResourceData, m any
132134 return diag .FromErr (err )
133135 }
134136
135- zone := scw .Zone (d .Get ("zone" ).(string ))
137+ var zonePtr * scw.Zone
138+
139+ if rawZone , ok := meta .GetRawConfigForKey (d , "zone" , cty .String ); ok && rawZone != nil && rawZone != "" {
140+ zone := scw .Zone (rawZone .(string ))
141+ zonePtr = & zone
142+ }
136143
137144 req := & s2svpn.CreateVpnGatewayRequest {
138145 Region : region ,
@@ -143,7 +150,7 @@ func ResourceVPNGatewayCreate(ctx context.Context, d *schema.ResourceData, m any
143150 PrivateNetworkID : regional .ExpandID (d .Get ("private_network_id" ).(string )).ID ,
144151 IpamPrivateIPv4ID : types .ExpandStringPtr (d .Get ("ipam_private_ipv4_id" ).(string )),
145152 IpamPrivateIPv6ID : types .ExpandStringPtr (d .Get ("ipam_private_ipv6_id" ).(string )),
146- Zone : & zone ,
153+ Zone : zonePtr ,
147154 PublicConfig : expandVPNGatewayPublicConfig (d .Get ("public_config" )),
148155 }
149156
0 commit comments