diff --git a/README.md b/README.md
index 682f9a3..9ddf3a8 100644
--- a/README.md
+++ b/README.md
@@ -51,11 +51,11 @@ module "my_instance" {
| [additional_volume_ids](#input_additional_volume_ids) | Additional volumes attached to the server. Updates to this field will trigger a stop/start of the server. | `list(string)` | `[]` | no |
| [boot_type](#input_boot_type) | The boot Type of the server. Default to 'local'. Possible values are: 'local', 'bootscript' or 'rescue'. | `string` | `"local"` | no |
| [bootscript_id](#input_bootscript_id) | ID of the bootscript to use (set boot_type to bootscript). | `string` | `null` | no |
-| [dns_zone](#input_dns_zone) | Domain name of the instance. If set, instance IPs will be registered in the matching DNS zone. | `string` | `null` | no |
+| [domainname](#input_domainname) | Domain name of the instance. If set, instance IPs will be registered in the matching DNS zone. | `string` | `null` | no |
| [enable_ipv6](#input_enable_ipv6) | Determines if IPv6 is enabled for the server. | `bool` | `false` | no |
| [enable_public_ipv4](#input_enable_public_ipv4) | Determines if a public IPv4 will be attached to the server. | `bool` | `false` | no |
+| [hostname](#input_hostname) | Name of the instance. If not set, it will be randomly generated by Scaleway. | `string` | `null` | no |
| [instance_type](#input_instance_type) | Commercial type of the server. Default to 'DEV1-S'. Updates to this field will recreate a new resource. | `string` | `"DEV1-S"` | no |
-| [name](#input_name) | Name of the instance. If not set, it will be randomly generated by Scaleway. | `string` | `null` | no |
| [placement_group_id](#input_placement_group_id) | ID of the placement group the server is attached to. | `string` | `null` | no |
| [private_networks](#input_private_networks) | Private networks associated with the server. | `list(string)` | `[]` | no |
| [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 |
diff --git a/main.tf b/main.tf
index 4f20164..f798eaf 100644
--- a/main.tf
+++ b/main.tf
@@ -4,9 +4,9 @@ moved {
}
locals {
- requested_fqdn = (var.name != null && var.dns_zone != null) ? format("%s.%s", var.name, var.dns_zone) : var.name
- effective_hostname = var.dns_zone != null ? trimsuffix(trimsuffix(scaleway_instance_server.this.name, var.dns_zone), ".") : scaleway_instance_server.this.name
- effective_fqdn = var.dns_zone != null ? format("%s.%s", local.effective_hostname, var.dns_zone) : local.effective_hostname
+ requested_fqdn = (var.hostname != null && var.domainname != null) ? format("%s.%s", var.hostname, var.domainname) : var.hostname
+ effective_hostname = var.domainname != null ? trimsuffix(trimsuffix(scaleway_instance_server.this.name, var.domainname), ".") : scaleway_instance_server.this.name
+ effective_fqdn = var.domainname != null ? format("%s.%s", local.effective_hostname, var.domainname) : local.effective_hostname
}
resource "scaleway_instance_ip" "this" {
@@ -17,7 +17,7 @@ resource "scaleway_instance_ip" "this" {
}
resource "scaleway_instance_ip_reverse_dns" "this" {
- count = var.enable_public_ipv4 && (var.dns_zone != null) ? 1 : 0
+ count = var.enable_public_ipv4 && (var.domainname != null) ? 1 : 0
ip_id = scaleway_instance_ip.this[count.index].id
reverse = local.effective_fqdn
@@ -61,19 +61,19 @@ resource "scaleway_instance_server" "this" {
}
resource "scaleway_domain_record" "ip4" {
- count = var.dns_zone != null ? 1 : 0
+ count = var.domainname != null ? 1 : 0
data = var.enable_public_ipv4 ? scaleway_instance_server.this.public_ip : scaleway_instance_server.this.private_ip
- dns_zone = var.dns_zone
+ dns_zone = var.domainname
name = local.effective_hostname
type = "A"
}
resource "scaleway_domain_record" "ip6" {
- count = var.dns_zone != null && var.enable_ipv6 && var.state != "stopped" ? 1 : 0
+ count = var.domainname != null && var.enable_ipv6 && var.state != "stopped" ? 1 : 0
data = scaleway_instance_server.this.ipv6_address
- dns_zone = var.dns_zone
+ dns_zone = var.domainname
name = local.effective_hostname
type = "AAAA"
}
diff --git a/variables.tf b/variables.tf
index 26784c9..469d2d5 100644
--- a/variables.tf
+++ b/variables.tf
@@ -10,13 +10,13 @@ variable "instance_type" {
}
# Instance settings
-variable "name" {
+variable "hostname" {
type = string
description = "Name of the instance. If not set, it will be randomly generated by Scaleway."
default = null
}
-variable "dns_zone" {
+variable "domainname" {
type = string
description = "Domain name of the instance. If set, instance IPs will be registered in the matching DNS zone."
default = null