Skip to content

Commit 9e163af

Browse files
authored
fix(rdb): schema corrections and examples (#2022)
1 parent f17fc09 commit 9e163af

File tree

2 files changed

+28
-61
lines changed

2 files changed

+28
-61
lines changed

docs/resources/rdb_instance.md

+18-40
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ resource "scaleway_rdb_instance" "main" {
5353
engine = "MySQL-8"
5454
user_name = "my_initial_user"
5555
password = "thiZ_is_v&ry_s3cret"
56-
init_settings = {
56+
init_settings = {
5757
"lower_case_table_names" = 1
5858
}
5959
settings = {
@@ -79,44 +79,18 @@ resource "scaleway_rdb_instance" "main" {
7979
}
8080
```
8181

82-
### Example with private network and dhcp configuration
82+
### Example with custom private network
8383

8484
```hcl
85-
resource "scaleway_vpc_private_network" "pn02" {
85+
# VPC PRIVATE NETWORK
86+
resource "scaleway_vpc_private_network" "pn" {
8687
name = "my_private_network"
88+
ipv4_subnet {
89+
subnet = "172.16.20.0/22"
90+
}
8791
}
8892
89-
resource "scaleway_vpc_public_gateway_dhcp" "main" {
90-
subnet = "192.168.1.0/24"
91-
}
92-
93-
resource "scaleway_vpc_public_gateway_ip" "main" {
94-
}
95-
96-
resource "scaleway_vpc_public_gateway" "main" {
97-
name = "foobar"
98-
type = "VPC-GW-S"
99-
ip_id = scaleway_vpc_public_gateway_ip.main.id
100-
}
101-
102-
resource "scaleway_vpc_public_gateway_pat_rule" "main" {
103-
gateway_id = scaleway_vpc_public_gateway.main.id
104-
private_ip = scaleway_vpc_public_gateway_dhcp.main.address
105-
private_port = scaleway_rdb_instance.main.private_network.0.port
106-
public_port = 42
107-
protocol = "both"
108-
depends_on = [scaleway_vpc_gateway_network.main, scaleway_vpc_private_network.pn02]
109-
}
110-
111-
resource "scaleway_vpc_gateway_network" "main" {
112-
gateway_id = scaleway_vpc_public_gateway.main.id
113-
private_network_id = scaleway_vpc_private_network.pn02.id
114-
dhcp_id = scaleway_vpc_public_gateway_dhcp.main.id
115-
cleanup_dhcp = true
116-
enable_masquerade = true
117-
depends_on = [scaleway_vpc_public_gateway_ip.main, scaleway_vpc_private_network.pn02]
118-
}
119-
93+
# RDB INSTANCE CONNECTED ON A CUSTOM PRIVATE NETWORK
12094
resource "scaleway_rdb_instance" "main" {
12195
name = "test-rdb"
12296
node_type = "db-dev-s"
@@ -130,8 +104,8 @@ resource "scaleway_rdb_instance" "main" {
130104
volume_type = "bssd"
131105
volume_size_in_gb = 10
132106
private_network {
133-
ip_net = "192.168.1.254/24" #pool high
134-
pn_id = scaleway_vpc_private_network.pn02.id
107+
ip_net = "172.16.20.4/22" # IP address within a given IP network
108+
pn_id = scaleway_vpc_private_network.pn.id
135109
}
136110
}
137111
```
@@ -197,6 +171,10 @@ available `settings` and `init_settings` on your `node_type` of your convenient.
197171

198172
~> **Important:** Updates to `private_network` will recreate the attachment Instance.
199173

174+
~> **NOTE:** Please calculate your host IP.
175+
using [cirhost](https://developer.hashicorp.com/terraform/language/functions/cidrhost). Otherwise, lets IPAM service
176+
handle the host IP on the network.
177+
200178
- `ip_net` - (Optional) The IP network address within the private subnet. This must be an IPv4 address with a
201179
CIDR notation. The IP network address within the private subnet is determined by the IP Address Management (IPAM)
202180
service if not set.
@@ -224,11 +202,11 @@ are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-1111111111
224202
- `name` - Name of the endpoint.
225203
- `hostname` - Name of the endpoint.
226204
- `private_network` - List of private networks endpoints of the database instance.
227-
- `endpoint_id` - The ID of the endpoint of the private network.
228-
- `ip` - IP of the endpoint.
229-
- `port` - Port of the endpoint.
205+
- `endpoint_id` - The ID of the endpoint.
206+
- `ip` - IPv4 address on the network.
207+
- `port` - Port in the Private Network.
230208
- `name` - Name of the endpoint.
231-
- `hostname` - Name of the endpoint.
209+
- `hostname` - Hostname of the endpoint.
232210
- `certificate` - Certificate of the database instance.
233211
- `organization_id` - The organization ID the Database Instance is associated with.
234212

scaleway/resource_rdb_instance.go

+10-21
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ func resourceScalewayRdbInstance() *schema.Resource {
148148
// Computed
149149
"endpoint_id": {
150150
Type: schema.TypeString,
151-
Optional: true,
152151
Computed: true,
153152
Description: "The endpoint ID",
154153
},
@@ -157,14 +156,12 @@ func resourceScalewayRdbInstance() *schema.Resource {
157156
Optional: true,
158157
Computed: true,
159158
ValidateFunc: validation.IsCIDR,
160-
Description: "The IP network address within the private subnet",
159+
Description: "The IP with the given mask within the private subnet",
161160
},
162161
"ip": {
163-
Type: schema.TypeString,
164-
Optional: true,
165-
Computed: true,
166-
ValidateFunc: validation.IsIPAddress,
167-
Description: "The IP of your private service",
162+
Type: schema.TypeString,
163+
Computed: true,
164+
Description: "The IP of your Instance within the private service",
168165
},
169166
"port": {
170167
Type: schema.TypeInt,
@@ -175,13 +172,11 @@ func resourceScalewayRdbInstance() *schema.Resource {
175172
},
176173
"name": {
177174
Type: schema.TypeString,
178-
Optional: true,
179175
Computed: true,
180176
Description: "The name of your private service",
181177
},
182178
"hostname": {
183179
Type: schema.TypeString,
184-
Optional: true,
185180
Computed: true,
186181
Description: "The hostname of your endpoint",
187182
},
@@ -244,28 +239,22 @@ func resourceScalewayRdbInstance() *schema.Resource {
244239
Description: "The endpoint ID",
245240
},
246241
"ip": {
247-
Type: schema.TypeString,
248-
Optional: true,
249-
Computed: true,
250-
ValidateFunc: validation.IsIPAddress,
251-
Description: "The IP of your load balancer service",
242+
Type: schema.TypeString,
243+
Computed: true,
244+
Description: "The IP of your load balancer service",
252245
},
253246
"port": {
254-
Type: schema.TypeInt,
255-
Optional: true,
256-
Computed: true,
257-
ValidateFunc: validation.IsPortNumber,
258-
Description: "The port of your load balancer service",
247+
Type: schema.TypeInt,
248+
Computed: true,
249+
Description: "The port of your load balancer service",
259250
},
260251
"name": {
261252
Type: schema.TypeString,
262-
Optional: true,
263253
Computed: true,
264254
Description: "The name of your load balancer service",
265255
},
266256
"hostname": {
267257
Type: schema.TypeString,
268-
Optional: true,
269258
Computed: true,
270259
Description: "The hostname of your endpoint",
271260
},

0 commit comments

Comments
 (0)