Skip to content

Commit d618a43

Browse files
authored
fix(vpc): only one of dhcp_id and static_address should be set (#1728)
1 parent 619e65f commit d618a43

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

docs/resources/vpc_gateway_network.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ For more information, see [the documentation](https://developers.scaleway.com/en
1212

1313
## Example
1414

15+
### Create a gateway network with DHCP
16+
1517
```hcl
1618
resource "scaleway_vpc_private_network" "pn01" {
1719
name = "pn_test_network"
@@ -40,17 +42,38 @@ resource "scaleway_vpc_gateway_network" "main" {
4042
}
4143
```
4244

45+
### Create a gateway network with a static IP address
46+
47+
```hcl
48+
resource scaleway_vpc_private_network pn01 {
49+
name = "pn_test_network"
50+
}
51+
52+
resource scaleway_vpc_public_gateway pg01 {
53+
name = "foobar"
54+
type = "VPC-GW-S"
55+
}
56+
57+
resource scaleway_vpc_gateway_network main {
58+
gateway_id = scaleway_vpc_public_gateway.pg01.id
59+
private_network_id = scaleway_vpc_private_network.pn01.id
60+
enable_dhcp = false
61+
enable_masquerade = true
62+
static_address = "192.168.1.42/24"
63+
}
64+
```
65+
4366
## Arguments Reference
4467

4568
The following arguments are supported:
4669

4770
- `gateway_id` - (Required) The ID of the public gateway.
4871
- `private_network_id` - (Required) The ID of the private network.
49-
- `dhcp_id` - (Required) The ID of the public gateway DHCP config.
72+
- `dhcp_id` - (Required) The ID of the public gateway DHCP config. Only one of `dhcp_id` and `static_address` should be specified.
5073
- `enable_masquerade` - (Defaults to true) Enable masquerade on this network
5174
- `enable_dhcp` - (Defaults to true) Enable DHCP config on this network. It requires DHCP id.
5275
- `cleanup_dhcp` - (Defaults to false) Remove DHCP config on this network on destroy. It requires DHCP id.
53-
- `static_address` - Enable DHCP config on this network
76+
- `static_address` - Enable DHCP config on this network. Only one of `dhcp_id` and `static_address` should be specified.
5477
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the gateway network should be created.
5578

5679
## Attributes Reference

scaleway/resource_vpc_gateway_network.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ func resourceScalewayVPCGatewayNetwork() *schema.Resource {
4343
Description: "The ID of the private network where connect to",
4444
},
4545
"dhcp_id": {
46-
Type: schema.TypeString,
47-
Optional: true,
48-
ValidateFunc: validationUUIDorUUIDWithLocality(),
49-
Description: "The ID of the public gateway DHCP config",
46+
Type: schema.TypeString,
47+
Optional: true,
48+
ValidateFunc: validationUUIDorUUIDWithLocality(),
49+
Description: "The ID of the public gateway DHCP config",
50+
ConflictsWith: []string{"static_address"},
5051
},
5152
"enable_masquerade": {
5253
Type: schema.TypeBool,
@@ -67,10 +68,11 @@ func resourceScalewayVPCGatewayNetwork() *schema.Resource {
6768
Description: "Remove DHCP config on this network on destroy",
6869
},
6970
"static_address": {
70-
Type: schema.TypeString,
71-
Description: "The static IP address in CIDR on this network",
72-
Optional: true,
73-
ValidateFunc: validation.IsCIDR,
71+
Type: schema.TypeString,
72+
Description: "The static IP address in CIDR on this network",
73+
Optional: true,
74+
ValidateFunc: validation.IsCIDR,
75+
ConflictsWith: []string{"dhcp_id"},
7476
},
7577
// Computed elements
7678
"mac_address": {

0 commit comments

Comments
 (0)