Skip to content

Commit 9265896

Browse files
committed
fix int type and update pat rule datasource test
1 parent ddb385b commit 9265896

File tree

3 files changed

+5309
-9
lines changed

3 files changed

+5309
-9
lines changed

internal/services/vpcgw/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func readVPCGWResourceDataV2(d *schema.ResourceData, gw *v2.Gateway) diag.Diagno
197197
_ = d.Set("bastion_enabled", gw.BastionEnabled)
198198
_ = d.Set("bastion_port", int(gw.BastionPort))
199199
_ = d.Set("enable_smtp", gw.SMTPEnabled)
200-
_ = d.Set("bandwidth", gw.Bandwidth)
200+
_ = d.Set("bandwidth", int(gw.Bandwidth))
201201
_ = d.Set("upstream_dns_servers", nil)
202202

203203
ips, err := FlattenIPNetList(gw.BastionAllowedIPs)

internal/services/vpcgw/pat_rule_data_source_test.go

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ func TestAccDataSourceVPCPublicGatewayPATRule_Basic(t *testing.T) {
2222
type = "VPC-GW-S"
2323
}
2424
25-
resource scaleway_vpc_public_gateway_dhcp dhcp01 {
26-
subnet = "192.168.1.0/24"
25+
resource scaleway_vpc vpc01 {
26+
name = "my vpc"
2727
}
2828
2929
resource scaleway_vpc_private_network pn01 {
3030
name = "pn_test_network"
31+
ipv4_subnet {
32+
subnet = "172.16.32.0/22"
33+
}
3134
}
3235
`,
3336
},
@@ -37,26 +40,45 @@ func TestAccDataSourceVPCPublicGatewayPATRule_Basic(t *testing.T) {
3740
type = "VPC-GW-S"
3841
}
3942
40-
resource scaleway_vpc_public_gateway_dhcp dhcp01 {
41-
subnet = "192.168.1.0/24"
43+
resource scaleway_vpc vpc01 {
44+
name = "my vpc"
4245
}
4346
4447
resource scaleway_vpc_private_network pn01 {
4548
name = "pn_test_network"
49+
ipv4_subnet {
50+
subnet = "172.16.32.0/22"
51+
}
4652
}
4753
4854
resource scaleway_vpc_gateway_network gn01 {
4955
gateway_id = scaleway_vpc_public_gateway.pg01.id
5056
private_network_id = scaleway_vpc_private_network.pn01.id
51-
dhcp_id = scaleway_vpc_public_gateway_dhcp.dhcp01.id
52-
depends_on = [scaleway_vpc_private_network.pn01]
53-
cleanup_dhcp = true
5457
enable_masquerade = true
58+
ipam_config {
59+
push_default_route = true
60+
}
61+
}
62+
63+
### Scaleway Instance
64+
resource "scaleway_instance_server" "main" {
65+
name = "Scaleway Instance"
66+
type = "DEV1-S"
67+
image = "debian_bullseye"
68+
69+
private_network {
70+
pn_id = scaleway_vpc_private_network.pn01.id
71+
}
72+
}
73+
74+
data "scaleway_ipam_ip" "main" {
75+
mac_address = scaleway_instance_server.main.private_network.0.mac_address
76+
type = "ipv4"
5577
}
5678
5779
resource scaleway_vpc_public_gateway_pat_rule main {
5880
gateway_id = scaleway_vpc_public_gateway.pg01.id
59-
private_ip = scaleway_vpc_public_gateway_dhcp.dhcp01.address
81+
private_ip = data.scaleway_ipam_ip.main.address
6082
private_port = 42
6183
public_port = 42
6284
protocol = "both"

0 commit comments

Comments
 (0)