Skip to content

Commit 1b2f1c1

Browse files
authored
feat: Add support IPAM (#31)
- Add Output to retrieve database instance IP - Add "ip_net" and "enable_ipam" in "private_network" as optional because we must use one and not both - Format documentation with tfdocs
1 parent 2290b5a commit 1b2f1c1

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module "my_cluster" {
4747
| <a name="input_backup_schedule_frequency"></a> [backup_schedule_frequency](#input_backup_schedule_frequency) | Backup schedule frequency in hours. | `number` | `24` | no |
4848
| <a name="input_backup_schedule_retention"></a> [backup_schedule_retention](#input_backup_schedule_retention) | Backup schedule retention in days. | `number` | `7` | no |
4949
| <a name="input_ha_enabled"></a> [ha_enabled](#input_ha_enabled) | Enable or disable high availability for the database instance. | `bool` | `false` | no |
50-
| <a name="input_private_network"></a> [private_network](#input_private_network) | Describes the private network you want to connect to your cluster. If not set, a public network will be provided. | ```object({ pn_id = string ip_net = string })``` | `null` | no |
50+
| <a name="input_private_network"></a> [private_network](#input_private_network) | Describes the private network you want to connect to your cluster. If not set, a public network will be provided. | ```object({ pn_id = string ip_net = optional(string) enable_ipam = optional(bool) })``` | `null` | no |
5151
| <a name="input_project_id"></a> [project_id](#input_project_id) | ID of the project the instance is associated with. Ressource will be created in the project set at the provider level if null. | `string` | `null` | no |
5252
| <a name="input_region"></a> [region](#input_region) | Region in which the instance should be created. Ressource will be created in the region set at the provider level if null. | `string` | `null` | no |
5353
| <a name="input_replica_enabled"></a> [replica_enabled](#input_replica_enabled) | Whether to create a read replica or not. | `bool` | `true` | no |
@@ -64,6 +64,7 @@ module "my_cluster" {
6464
|------|-------------|
6565
| <a name="output_cluster_certificate"></a> [cluster_certificate](#output_cluster_certificate) | PEM Certificate of the database instance. |
6666
| <a name="output_instance_id"></a> [instance_id](#output_instance_id) | ID of the Database Instance. |
67+
| <a name="output_instance_ip"></a> [instance_ip](#output_instance_ip) | Database instance IP |
6768
| <a name="output_load_balancer"></a> [load_balancer](#output_load_balancer) | List of load balancer endpoints of the database instance. |
6869
| <a name="output_replicate_pn"></a> [replicate_pn](#output_replicate_pn) | Private network attributes of the read replica. |
6970
| <a name="output_user_password"></a> [user_password](#output_user_password) | Password generated if non were given. |

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ resource "scaleway_rdb_instance" "this" {
3333
dynamic "private_network" {
3434
for_each = var.private_network != null ? [1] : []
3535
content {
36-
pn_id = try(var.private_network.pn_id, null)
37-
ip_net = try(var.private_network.ip_net, null)
36+
pn_id = try(var.private_network.pn_id, null)
37+
ip_net = try(var.private_network.ip_net, null)
38+
enable_ipam = try(var.private_network.enable_ipam, false)
3839
}
3940
}
4041
}

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ output "instance_id" {
88
value = scaleway_rdb_instance.this.id
99
}
1010

11+
output "instance_ip" {
12+
description = "Database instance IP"
13+
value = scaleway_rdb_instance.this.private_network[*].ip
14+
}
15+
1116
output "load_balancer" {
1217
description = "List of load balancer endpoints of the database instance."
1318
value = scaleway_rdb_instance.this.load_balancer

variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ variable "node_type" {
2424
variable "private_network" {
2525
description = "Describes the private network you want to connect to your cluster. If not set, a public network will be provided."
2626
type = object({
27-
pn_id = string
28-
ip_net = string
27+
pn_id = string
28+
ip_net = optional(string)
29+
enable_ipam = optional(bool)
2930
})
3031
default = null
3132
}

0 commit comments

Comments
 (0)