scaleway / terraform-provider-scaleway

Terraform Scaleway provider
https://www.terraform.io/docs/providers/scaleway/
Mozilla Public License 2.0
199 stars 126 forks source link

Resource scaleway_k8s_cluster in 2.32.0 removing private network on destroying #2214

Closed a-devops-guy closed 11 months ago

a-devops-guy commented 1 year ago

Resource scaleway_k8s_cluster in 2.32.0 removing private network on destroying. Private network was created manually on UI but still terraform destroy is removing the private network in the end. Which results in creating private network every time when I do terraform apply

Mia-Cross commented 11 months ago

Hello @a-devops-guy

Indeed this is caused by the delete_additional_resources attribute. If it is set to true, the cluster will be deleted with the resources that are linked to it, like volumes, load-balancers and the private network if it's empty. The documentation only mentions volumes and load-balancers so I will add this information, thanks for pointing it out !

To avoid recreating the private network manually every time, maybe you could define the private network in your Terraform code :

resource "scaleway_vpc" "vpc" {}

resource "scaleway_vpc_private_network" "pn" {
  vpc_id = scaleway_vpc.vpc.id
}

resource "scaleway_k8s_cluster" "cluster" {
  type = "kapsule"
  version = "1.28.2"
  cni = "cilium"
  private_network_id = scaleway_vpc_private_network.pn.id
  delete_additional_resources = true
}

Another solution would be to have another resource in the private network, unrelated to the cluster, as the private network will not be deleted if it's not empty.