Open gmalfray opened 1 month ago
I'm replying to myself: private_ip is deprecated (https://www.scaleway.com/en/developers/api/instance/#path-instances-list-all-instances-query-privateip). The solution is to create the resource scaleway_instance_private_nic and then load data "scaleway_ipam_ip".
resource "scaleway_instance_server" "proxy" {
type = "DEV1-S"
project_id = var.project_id
count = var.nbproxy
name = "${var.basename_proxy}${count.index + 1}.${var.domain}"
image = var.image
zone = "fr-par-2"
user_data = {
cloud-init = data.template_file.userdataproxy.rendered
}
}
resource "scaleway_instance_private_nic" "proxy" {
count = var.nbproxy
server_id = scaleway_instance_server.proxy[count.index].id
private_network_id = data.scaleway_vpc_private_network.pvn-pra-gdest.private_network_id
}
data "scaleway_ipam_ip" "by_id_proxy" {
count = var.nbproxy
resource {
id = scaleway_instance_private_nic.proxy[count.index].id
type = "instance_private_nic"
}
type = "ipv4"
}
resource "scaleway_domain_record" "proxy" {
count = var.nbproxy
dns_zone = var.domain
name = "${var.basename_proxy}${count.index + 1}"
type = "A"
data = data.scaleway_ipam_ip.by_id_proxy[count.index].address
ttl = 3600
}
Thanks for the feedback, I have the same issue but didn't see the deprecation here: https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/data-sources/instance_server#private_ip-2 Indeed, it's indicated in the API spec
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Expected Behavior
The private_ip field should return the private IP address of the instance once it is connected to the specified private network
Actual Behavior
The private_ip field is null in the output, even though the instance is successfully created and attached to the private network.
Steps to Reproduce
Define a scaleway_instance_server resource with a private network. Run terraform apply. Observe that the private_ip field in the output is null.
Additional Context
The Scaleway instance is being created in the fr-par-2 zone. The issue occurs even though the instance is correctly attached to the private network, as indicated by the network. A private IP address is indeed assigned to the resource.
References
No response