Skip to content

Commit 3fa0c59

Browse files
committed
chore(instance)!: Phased out nat IPs and force use of routed IPs
1 parent 84d8645 commit 3fa0c59

File tree

6 files changed

+8
-16
lines changed

6 files changed

+8
-16
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ module "my_instance" {
6464
| <a name="input_private_networks"></a> [private_networks](#input_private_networks) | Private networks associated with the server. | `list(string)` | `[]` | no |
6565
| <a name="input_project_id"></a> [project_id](#input_project_id) | ID of the project the namespace is associated with. Ressource will be created in the project set at the provider level if null. | `string` | `null` | no |
6666
| <a name="input_root_volume"></a> [root_volume](#input_root_volume) | Root volume attached to the server on creation. Updates to `root_volume.size_in_gb` will be ignored after the creation of the server. | ```object({ delete_on_termination = bool size_in_gb = number volume_id = optional(string) volume_type = optional(string) })``` | `null` | no |
67-
| <a name="input_routed_ip_enabled"></a> [routed_ip_enabled](#input_routed_ip_enabled) | Determine if the instance will support routed ips only. Changing it to true will migrate the server and its IP to routed type. | `bool` | `true` | no |
6867
| <a name="input_security_group_id"></a> [security_group_id](#input_security_group_id) | ID of the security group the server is attached to. | `string` | `null` | no |
6968
| <a name="input_state"></a> [state](#input_state) | State of the server. Default to 'started'. Possible values are: 'started', 'stopped' or 'standby'. | `string` | `"started"` | no |
7069
| <a name="input_tags"></a> [tags](#input_tags) | Tags associated with the server and dedicated ip address. | `list(string)` | `[]` | no |

ipv4.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resource "scaleway_instance_ip" "public_ipv4" {
1717
count = var.enable_public_ipv4 ? 1 : 0
1818

1919
project_id = var.project_id
20-
type = var.routed_ip_enabled ? "routed_ipv4" : "nat"
20+
type = "routed_ipv4"
2121
zone = var.zone
2222
}
2323

ipv6.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ moved {
44
}
55

66
resource "scaleway_instance_ip" "ipv6" {
7-
count = var.enable_ipv6 && var.routed_ip_enabled ? 1 : 0
7+
count = var.enable_ipv6 ? 1 : 0
88

99
project_id = var.project_id
1010
type = "routed_ipv6"
1111
zone = var.zone
1212
}
1313

1414
resource "scaleway_instance_ip_reverse_dns" "ipv6" {
15-
count = var.enable_ipv6 && var.routed_ip_enabled && (var.domainname != null) ? 1 : 0
15+
count = var.enable_ipv6 && (var.domainname != null) ? 1 : 0
1616

1717
ip_id = scaleway_instance_ip.ipv6[count.index].id
1818
reverse = local.effective_fqdn
@@ -22,7 +22,7 @@ resource "scaleway_instance_ip_reverse_dns" "ipv6" {
2222
resource "scaleway_domain_record" "ipv6" {
2323
count = var.domainname != null && var.enable_ipv6 && var.state != "stopped" ? 1 : 0
2424

25-
data = var.routed_ip_enabled ? one([for item in scaleway_instance_server.this.public_ips[*].address : item if can(regex(":", item))]) : scaleway_instance_server.this.ipv6_address
25+
data = one([for item in scaleway_instance_server.this.public_ips[*].address : item if can(regex(":", item))])
2626
dns_zone = var.domainname
2727
name = local.effective_hostname
2828
type = "AAAA"

main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ resource "scaleway_instance_server" "this" {
2020
}
2121

2222
enable_dynamic_ip = var.enable_public_ipv4
23-
enable_ipv6 = var.routed_ip_enabled ? null : var.enable_ipv6
24-
routed_ip_enabled = var.routed_ip_enabled
23+
enable_ipv6 = null
2524

2625
ip_ids = compact(tolist([
2726
var.enable_public_ipv4 ? scaleway_instance_ip.public_ipv4[0].id : null,
28-
var.enable_ipv6 && var.routed_ip_enabled ? scaleway_instance_ip.ipv6[0].id : null,
27+
var.enable_ipv6 ? scaleway_instance_ip.ipv6[0].id : null,
2928
]))
3029

3130
dynamic "private_network" {

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
output "ip4" {
22
description = "IPv4 address of the intance."
3-
value = var.enable_public_ipv4 ? (var.routed_ip_enabled ? scaleway_instance_ip.public_ipv4[0].address : scaleway_instance_server.this.public_ip) : scaleway_instance_server.this.private_ip
3+
value = var.enable_public_ipv4 ? scaleway_instance_ip.public_ipv4[0].address : scaleway_instance_server.this.private_ip
44
}
55

66
output "ip6" {
77
description = "IPv6 address of the instance."
8-
value = var.enable_ipv6 && var.routed_ip_enabled ? one([for item in scaleway_instance_server.this.public_ips[*].address : item if can(regex(":", item))]) : scaleway_instance_server.this.ipv6_address
8+
value = var.enable_ipv6 ? one([for item in scaleway_instance_server.this.public_ips[*].address : item if can(regex(":", item))]) : scaleway_instance_server.this.ipv6_address
99
}
1010

1111
output "name" {

variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ variable "enable_public_ipv4" {
7373
default = false
7474
}
7575

76-
variable "routed_ip_enabled" {
77-
type = bool
78-
description = "Determine if the instance will support routed ips only. Changing it to true will migrate the server and its IP to routed type."
79-
default = true
80-
}
81-
8276
variable "private_networks" {
8377
type = list(string)
8478
description = "Private networks associated with the server."

0 commit comments

Comments
 (0)