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

[Feature] - Handle VPC deletion when attached to other resources #363

Open
optik-aper opened this issue May 18, 2023 · 0 comments
Open

[Feature] - Handle VPC deletion when attached to other resources #363

optik-aper opened this issue May 18, 2023 · 0 comments
Assignees

Comments

@optik-aper
Copy link
Member

Describe the bug
VPCs aren't properly deleted when they are attached because there is no way to check what it's attached to. With VPC 2.0 this might be possible so we should support checking if the network is attached to instances before we allow deletion.

To Reproduce

  • Create a VPC, instance or load balancer and connect them
resource "vultr_instance" "oof" {
  region = "mel"
  tags = ["terraform"]
  label = "tf-lb-test"
  plan = "vhp-2c-2gb-amd"
  os_id = 1946
}

resource "vultr_vpc" "bar" {
  region   = "mel"
  description = "bar"
}

resource "vultr_load_balancer" "foo" {
  region   = "mel"
  label       = "%s"

  forwarding_rules {
    frontend_protocol = "http"
    frontend_port     = 80
    backend_protocol  = "http"
    backend_port      = 80
  }
  vpc = vultr_vpc.bar.id
  attached_instances = [vultr_instance.oof.id]
}
  • Remove the VPC
resource "vultr_instance" "oof" {
  region = "mel"
  tags = ["terraform"]
  label = "tf-lb-test"
  plan = "vhp-2c-2gb-amd"
  os_id = 1946
}

# resource "vultr_vpc" "bar" {
#   region   = "mel"
#   description = "bar"
# }

resource "vultr_load_balancer" "foo" {
  region   = "mel"
  label       = "%s"

  forwarding_rules {
    frontend_protocol = "http"
    frontend_port     = 80
    backend_protocol  = "http"
    backend_port      = 80
  }
  # vpc = vultr_vpc.bar.id
  attached_instances = [vultr_instance.oof.id]
}
  • The delete will fail because it's trying to delete the VPC before it is removed/detached from the load balancer

Expected behavior
Correctly determine what is attached to the VPC and remove/detach it before deletion

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

No branches or pull requests

1 participant