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

Cannot change Private IP Address in Created PAT Rule #1220

Closed
Iryos opened this issue Apr 19, 2022 · 1 comment · Fixed by #1242, #1243 or #1248
Closed

Cannot change Private IP Address in Created PAT Rule #1220

Iryos opened this issue Apr 19, 2022 · 1 comment · Fixed by #1242, #1243 or #1248
Assignees
Labels
bug vpc Virtual Private Cloud (VPC) issues, bugs and feature requests
Milestone

Comments

@Iryos
Copy link

Iryos commented Apr 19, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v1.1.8

Affected Resource(s)

  • scaleway_vpc_public_gateway_pat_rule

Terraform Configuration Files

### Scaleway Private Network
resource "scaleway_vpc_private_network" "monitoring" {
  name = "Monitoring"
}

### IP for Public Gateway
resource "scaleway_vpc_public_gateway_ip" "monitoring_vpc_ip" {
}

### DHCP Space of VPC
resource "scaleway_vpc_public_gateway_dhcp" "monitoring_vpc_dhcp" {
  subnet = "10.0.0.0/24"
}

### The Public Gateway with the Attached IP
resource "scaleway_vpc_public_gateway" "monitoring_vpc_gw" {
  name  = "Monitoring"
  type  = "VPC-GW-S"
  ip_id = scaleway_vpc_public_gateway_ip.monitoring_vpc_ip.id
}

### VPC Gateway Network
resource "scaleway_vpc_gateway_network" "monitoring_vpc_gw_network" {
  gateway_id         = scaleway_vpc_public_gateway.monitoring_vpc_gw.id
  private_network_id = scaleway_vpc_private_network.monitoring.id
  dhcp_id            = scaleway_vpc_public_gateway_dhcp.monitoring_vpc_dhcp.id
  cleanup_dhcp       = true
  enable_masquerade  = true
  depends_on = [
    scaleway_vpc_public_gateway_ip.monitoring_vpc_ip,
    scaleway_vpc_private_network.monitoring
  ]
}

### Elastic Stack Instance
resource "scaleway_instance_server" "elastic_stack_instance" {
  name        = "Elastic Stack"
  type        = "DEV1-S"
  image       = "debian_bullseye"
  tags        = ["Elastic Stack"]
  enable_ipv6 = false

  user_data = {
    cloud-init = file("${path.module}/cloud_init/default.yml")
  }

  private_network {
    pn_id = scaleway_vpc_private_network.monitoring.id
  }

}

### DHCP Reservation for Elastic Stack Instance
resource "scaleway_vpc_public_gateway_dhcp_reservation" "elastic_stack_dhcp_ip" {
  gateway_network_id = scaleway_vpc_gateway_network.monitoring_vpc_gw_network.id
  mac_address        = scaleway_instance_server.elastic_stack_instance.private_network.0.mac_address
  ip_address         = "10.0.0.3"
}

### Elastic Stack SSH Port
resource "scaleway_vpc_public_gateway_pat_rule" "elastic_stack_instance_ssh" {
  gateway_id   = scaleway_vpc_public_gateway.monitoring_vpc_gw.id
  private_ip   = scaleway_vpc_public_gateway_dhcp_reservation.elastic_stack_dhcp_ip.ip_address
  private_port = 22
  public_port  = 2023
  protocol     = "tcp"
  depends_on = [
    scaleway_vpc_gateway_network.monitoring_vpc_gw_network,
    scaleway_vpc_private_network.monitoring
  ]
}

Expected Behavior

The Private IP Address of the PAT Rule should change

Actual Behavior

Terraform throws this Error:

│ Error: Provider produced inconsistent final plan

│ When expanding the plan for
│ scaleway_vpc_public_gateway_pat_rule.elastic_stack_instance_ssh to include
│ new values learned so far during apply, provider
│ "registry.terraform.io/scaleway/scaleway" produced an invalid new value for
│ .private_ip: was cty.StringVal("10.0.0.3"), but now
│ cty.StringVal("10.0.0.227").

│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Steps to Reproduce

  1. terraform apply
  2. Change IP of DHCP Reservation or only the PrivateIP in the PAT Rule
  3. terraform apply
@remyleone remyleone added vpc Virtual Private Cloud (VPC) issues, bugs and feature requests bug labels Apr 19, 2022
@remyleone remyleone added this to the v2.2.1 milestone Apr 19, 2022
@jacquesbh
Copy link

I may have a similar issue, so I'll develop a bit here.

Considering the following terraform:

resource "scaleway_vpc_private_network" "pn_priv" {
  name = "subnet_all"
}
resource "scaleway_vpc_public_gateway_ip" "gw01" {}
resource "scaleway_vpc_public_gateway_dhcp" "dhcp01" {
  subnet = "192.168.1.0/24"
  push_default_route = true
  push_dns_server = true
  enable_dynamic = true
  dns_server_override = ["192.168.1.1"]
}
resource "scaleway_vpc_public_gateway" "pgw01" {
  name = "public gateway"
  type = "VPC-GW-S"
  ip_id = scaleway_vpc_public_gateway_ip.gw01.id
}
resource "scaleway_vpc_gateway_network" "main" {
  gateway_id = scaleway_vpc_public_gateway.pgw01.id
  private_network_id = scaleway_vpc_private_network.pn_priv.id
  dhcp_id = scaleway_vpc_public_gateway_dhcp.dhcp01.id
  cleanup_dhcp = true
  enable_masquerade = true
  enable_dhcp = true
  depends_on = [scaleway_vpc_public_gateway_ip.gw01, scaleway_vpc_private_network.pn_priv]
}
resource "scaleway_instance_server" "front_node" {
  count = 1
  name = "front-node${count.index+1}"
  type = "DEV1-S"
  image = "debian_bullseye"
  private_network {
    pn_id = scaleway_vpc_private_network.pn_priv.id
  }
  cloud_init = templatefile("./cloud-init/front_user_data.yaml", {})
  user_data = {"cloud-init": templatefile("./cloud-init/front_user_data.yaml", {})}
}
resource scaleway_instance_private_nic front {
  count = 1
  private_network_id = scaleway_vpc_private_network.pn_priv.id
  server_id = scaleway_instance_server.front_node[count.index].id
}
resource scaleway_vpc_public_gateway_dhcp_reservation front {
  count = 1
  gateway_network_id = scaleway_vpc_gateway_network.main.id
  mac_address = scaleway_instance_private_nic.front[count.index].mac_address
  ip_address = "192.168.1.${count.index+100}"
}

The server should have the 192.168.1.100 ip address. But it gets another one.

It's like the server gets an IP address using DHCP dynamic addressing (which is fine…), but it never renews its lease to get the static IP address specified in the DHCP reservation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment