opentelekomcloud / terraform-provider-opentelekomcloud

Terraform OpenTelekomCloud provider
https://registry.terraform.io/providers/opentelekomcloud/opentelekomcloud/latest
Mozilla Public License 2.0
87 stars 78 forks source link

Changing of subnet's DNS settings is not a one-step process #1922

Open IngIhorMuzychka opened 2 years ago

IngIhorMuzychka commented 2 years ago

Hі, colleagues!

I met with the strange work of opentelekomcloud_vpc_subnet_v1. When I create a resource without specifying the primary and secondary DNS I get the expected result (with default values):

resource "opentelekomcloud_vpc_subnet_v1" "subnet" {
  name          = "subnet-${var.project_name}"
  vpc_id        = opentelekomcloud_vpc_v1.vpc-1.id
  cidr          = var.project.frontend_subnet_cidr
  gateway_ip    = var.project.frontend_gateway_ip  
  tags          = var.tags
}

When I try to add or change existing values ​​in the created resource (for example, secondary DNS) and do not touch the primary one, it looks good on the plan, but after applying these changes, the secondary DNS overrides the primary and only one remains.

So, one subnet is already created based on this code:

resource "opentelekomcloud_vpc_subnet_v1" "subnet" {
  name          = "subnet-${var.project_name}"
  vpc_id        = opentelekomcloud_vpc_v1.vpc-1.id
  cidr          = var.project.frontend_subnet_cidr
  gateway_ip    = var.project.frontend_gateway_ip
  primary_dns   = "100.125.4.25"
  secondary_dns = "100.125.129.199"  
  tags          = var.tags
}

I want to make the following changes: secondary_dns = "100.125.129.199" -> "100.125.129.200"

Planning results:

Terraform will perform the following actions:

  # module.network.opentelekomcloud_vpc_subnet_v1.subnet will be updated in-place
  ~ resource "opentelekomcloud_vpc_subnet_v1" "subnet" {
        id              = "3c4f51cb-f7fc-4dc6-ac2b-8e2c7b721b66"
        name            = "subnet-project-name"
      ~ secondary_dns   = "100.125.129.199" -> "100.125.129.200"
        # (10 unchanged attributes hidden)
    }

So, keeping the same parameters as before, I run the plan again and get the following result:

Terraform will perform the following actions:

  # module.network.opentelekomcloud_vpc_subnet_v1.subnet will be updated in-place
  ~ resource "opentelekomcloud_vpc_subnet_v1" "subnet" {
        id            = "3c4f51cb-f7fc-4dc6-ac2b-8e2c7b721b66"
        name          = "subnet-project-name"
      ~ primary_dns   = "100.125.129.200" -> "100.125.4.25"
      + secondary_dns = "100.125.129.200"
        # (10 unchanged attributes hidden)
    }

After that I get the expected result, I wanted from the beginning, but after 2 runs of apply command..

It was originally planned, or is it a bug? The problem is not critical, but it brings discomfort..

I will be grateful for a hint or an answer, thanks!

anton-sidelnikov commented 2 years ago

@IngIhorMuzychka Hi this is a bug, created internal incident ONS-11395