diff --git a/terraform/main.tf b/terraform/main.tf index 3d82fbd3f4211e4405abbfcdccedfd182e521308..6868449f05696295f811349c8c442ed4797c7382 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -14,7 +14,7 @@ resource "scaleway_instance_ip" "public_ip" { resource "scaleway_domain_record" "subdomain_record" { count = var.INSTANCE_COUNT dns_zone = var.PROJECT_DOMAIN - name = "${var.ENVIRONMENT}-${count.index}" + name = var.INSTANCE_COUNT == 1 ? "${var.ENVIRONMENT}" : ${var.ENVIRONMENT}-${count.index} type = "A" data = scaleway_instance_ip.public_ip[count.index].address ttl = 3600 @@ -23,7 +23,7 @@ resource "scaleway_domain_record" "subdomain_record" { resource "scaleway_domain_record" "host_subdomain_record" { count = var.INSTANCE_COUNT dns_zone = var.PROJECT_DOMAIN - name = "*.${var.ENVIRONMENT}-${count.index}" + name = var. INSTANCE_COUNT == 1 ? "*.${var.ENVIRONMENT}" : "*.${var.ENVIRONMENT}-${count.index}" type = "A" data = scaleway_instance_ip.public_ip[count.index].address ttl = 3600 @@ -58,7 +58,7 @@ resource "scaleway_instance_security_group" "www" { resource "scaleway_instance_server" "user_instance_server" { count = var.INSTANCE_COUNT project_id = var.SCW_PROJECT_ID - name = "instance${count.index}-${var.ENVIRONMENT}" + name = var.INSTANCE_COUNT == 1 ? "instance-${ENVIRONMENT}" : "instance${count.index}-${var.ENVIRONMENT}" type = var.INSTANCE_TYPE image = "ubuntu_jammy" ip_id = scaleway_instance_ip.public_ip[count.index].id