Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private_ip is null for scaleway_instance_server resource #2772

Open
gmalfray opened this issue Oct 15, 2024 · 2 comments
Open

private_ip is null for scaleway_instance_server resource #2772

gmalfray opened this issue Oct 15, 2024 · 2 comments
Assignees
Labels
documentation instance Instance issues, bugs and feature requests priority:highest Bugs filled by customers, security issues

Comments

@gmalfray
Copy link

gmalfray commented Oct 15, 2024

Terraform Version

Terraform v1.9.7

Affected Resource(s)

  • scaleway_instance_server

Terraform Configuration Files

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      = "debian_bookworm"
  zone       = "fr-par-2"
  user_data = {
    cloud-init = data.template_file.userdataproxy.rendered
  }
  private_network {
    pn_id = data.scaleway_vpc_private_network.pvn-pra-plop.private_network_id
  }
}

Debug Output

"private_ip" = tostring(null)
"private_network" = tolist([
  {
    "mac_address" = "02:00:00:2f:c8:4f"
    "pn_id" = "fr-par/c079e90b-4b31-4e1a-9af7-7f6bcbb1d5fd"
    "pnic_id" = "bc2f70f6-68ac-498e-b6f8-f1dec36f62db"
    "status" = "available"
    "zone" = "fr-par"
  },
])

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

@gmalfray
Copy link
Author

gmalfray commented Oct 16, 2024

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
}

@Codelax Codelax added documentation instance Instance issues, bugs and feature requests priority:high New features priority:highest Bugs filled by customers, security issues and removed priority:high New features labels Oct 17, 2024
@Codelax Codelax self-assigned this Oct 17, 2024
@Simbud-7
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation instance Instance issues, bugs and feature requests priority:highest Bugs filled by customers, security issues
Projects
None yet
Development

No branches or pull requests

3 participants