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

Some combination of cloud account/region resources are perpetually seeing changes without applying them properly #396

Closed
rnelson0 opened this issue Sep 17, 2021 · 3 comments
Labels
bug Bug duplicate Duplicate

Comments

@rnelson0
Copy link
Contributor

vRA Version

8.4.1

Terraform Version

1.0.4

vRA Terraform Provider Version

0.3.11

Affected Resource(s)

  • vra_cloud_account_vmc
  • vra_region
  • vra_zone
    --->

Terraform Configuration Files

# vra_cloud_account_vmc.bedford_vcenter:
resource "vra_cloud_account_vmc" "bedford_vcenter" {
  accept_self_signed_cert = var.insecure
  description             = "Label: \"Bedford\""
  api_token               = var.refresh_token
  name                    = "Bedford vCenter"
  regions = [
    "Datacenter:datacenter-58",
    "Datacenter:datacenter-488",
  ]
  vcenter_hostname = var.bedford_hostname
  vcenter_password = var.vcenter_password
  vcenter_username = var.vcenter_username
  nsx_hostname     = ""
  sddc_name        = ""

  lifecycle {
    ignore_changes = [
      api_token, regions
    ]
  }
}

# vra_region.bedford_region
data "vra_region" "bedford_region" {
  cloud_account_id = resource.vra_cloud_account_vmc.bedford_vcenter.id
  region = "Datacenter:datacenter-58"
}

# vra_zone.bedford_zone:
resource "vra_zone" "bedford_zone" {
  description      = ""
  folder           = "IaaS/EXSRE/vRA Deploys"
  name             = "Bedford vCenter / Bedford"
  placement_policy = "DEFAULT"
  region_id        = data.vra_region.bedford_region.id

  tags {
    key   = "dev-vra"
    value = "target"
  }
  tags {
    key   = "vcenter"
    value = "Bedford"
  }

  lifecycle {
    ignore_changes = [
      links,
    ]
  }
}

# vra_region.belfast_region
data "vra_region" "belfast_region" {
  cloud_account_id = resource.vra_cloud_account_vmc.bedford_vcenter.id
  region = "Datacenter:datacenter-488"
}

# vra_zone.belfast_zone:
resource "vra_zone" "belfast_zone" {
  description      = "Belfast datacenter zone"
  folder           = "IaaS/EXSRE/vRA Deploys"
  name             = "Bedford vCenter / Belfast"
  placement_policy = "DEFAULT"
  region_id        = data.vra_region.belfast_region.id

  tags {
    key   = "vcenter"
    value = "Belfast"
  }

  lifecycle {
    ignore_changes = [
      links,
    ]
  }
}

Expected Behavior

This should apply once and then (without external changes) show no planned or applied changes on subsequent runs

Actual Behavior

Every run shows the same planned and applied changes

# First run
erraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place
 <= read (data resources)

Terraform will perform the following actions:

  # module.vra-tf-eisre-infra.data.vra_region.bedford_region will be read during apply
  # (config refers to values not yet known)
 <= data "vra_region" "bedford_region"  {
      + created_at         = (known after apply)
      ~ external_region_id = "Datacenter:datacenter-58" -> (known after apply)
      ~ id                 = "d9ccd787-05e1-4f3b-9dc1-ed325a4d5741" -> (known after apply)
      ~ name               = "Bedford" -> (known after apply)
      ~ org_id             = "d80b28c6-1896-41e5-9292-54670ea5d3ba" -> (known after apply)
      + owner              = (known after apply)
      ~ updated_at         = "2020-05-06" -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # module.vra-tf-eisre-infra.data.vra_region.belfast_region will be read during apply
  # (config refers to values not yet known)
 <= data "vra_region" "belfast_region"  {
      + created_at         = (known after apply)
      ~ external_region_id = "Datacenter:datacenter-488" -> (known after apply)
      ~ id                 = "d3b54716-b69f-4e36-a97d-287c1448df00" -> (known after apply)
      ~ name               = "Belfast" -> (known after apply)
      ~ org_id             = "d80b28c6-1896-41e5-9292-54670ea5d3ba" -> (known after apply)
      + owner              = (known after apply)
      ~ updated_at         = "2021-09-17" -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # module.vra-tf-eisre-infra.vra_cloud_account_vmc.bedford_vcenter will be updated in-place
  ~ resource "vra_cloud_account_vmc" "bedford_vcenter" {
        id                      = "37eabfeb-df3e-4b64-84cf-791adc435684"
        name                    = "Bedford vCenter"
      ~ regions                 = [
          - "Datacenter:datacenter-488",
            "Datacenter:datacenter-58",
          + "Datacenter:datacenter-488",
        ]
        # (14 unchanged attributes hidden)
    }

  # module.vra-tf-eisre-infra.vra_zone.bedford_zone will be updated in-place
  ~ resource "vra_zone" "bedford_zone" {
        id                 = "6dc9a216-d5ac-410b-9f45-507e3e6019e1"
        name               = "Bedford vCenter / Bedford"
      ~ region_id          = "d9ccd787-05e1-4f3b-9dc1-ed325a4d5741" -> (known after apply)
        # (8 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # module.vra-tf-eisre-infra.vra_zone.belfast_zone will be updated in-place
  ~ resource "vra_zone" "belfast_zone" {
        id                 = "384b3743-2f16-4622-b146-d47aeb563e36"
        name               = "Bedford vCenter / Belfast"
      ~ region_id          = "d3b54716-b69f-4e36-a97d-287c1448df00" -> (known after apply)
        # (9 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 3 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.vra-tf-eisre-infra.vra_cloud_account_vmc.bedford_vcenter: Modifying... [id=37eabfeb-df3e-4b64-84cf-791adc435684]
module.vra-tf-eisre-infra.vra_cloud_account_vmc.bedford_vcenter: Modifications complete after 4s [id=37eabfeb-df3e-4b64-84cf-791adc435684]
module.vra-tf-eisre-infra.data.vra_region.bedford_region: Reading... [id=d9ccd787-05e1-4f3b-9dc1-ed325a4d5741]
module.vra-tf-eisre-infra.data.vra_region.belfast_region: Reading... [id=d3b54716-b69f-4e36-a97d-287c1448df00]
module.vra-tf-eisre-infra.data.vra_region.belfast_region: Read complete after 0s [id=d3b54716-b69f-4e36-a97d-287c1448df00]
module.vra-tf-eisre-infra.data.vra_region.bedford_region: Read complete after 0s [id=d9ccd787-05e1-4f3b-9dc1-ed325a4d5741]
# Second run
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place
 <= read (data resources)

Terraform will perform the following actions:

  # module.vra-tf-eisre-infra.data.vra_region.bedford_region will be read during apply
  # (config refers to values not yet known)
 <= data "vra_region" "bedford_region"  {
      + created_at         = (known after apply)
      ~ external_region_id = "Datacenter:datacenter-58" -> (known after apply)
      ~ id                 = "d9ccd787-05e1-4f3b-9dc1-ed325a4d5741" -> (known after apply)
      ~ name               = "Bedford" -> (known after apply)
      ~ org_id             = "d80b28c6-1896-41e5-9292-54670ea5d3ba" -> (known after apply)
      + owner              = (known after apply)
      ~ updated_at         = "2020-05-06" -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # module.vra-tf-eisre-infra.data.vra_region.belfast_region will be read during apply
  # (config refers to values not yet known)
 <= data "vra_region" "belfast_region"  {
      + created_at         = (known after apply)
      ~ external_region_id = "Datacenter:datacenter-488" -> (known after apply)
      ~ id                 = "d3b54716-b69f-4e36-a97d-287c1448df00" -> (known after apply)
      ~ name               = "Belfast" -> (known after apply)
      ~ org_id             = "d80b28c6-1896-41e5-9292-54670ea5d3ba" -> (known after apply)
      + owner              = (known after apply)
      ~ updated_at         = "2021-09-17" -> (known after apply)
        # (2 unchanged attributes hidden)
    }

  # module.vra-tf-eisre-infra.vra_cloud_account_vmc.bedford_vcenter will be updated in-place
  ~ resource "vra_cloud_account_vmc" "bedford_vcenter" {
        id                      = "37eabfeb-df3e-4b64-84cf-791adc435684"
        name                    = "Bedford vCenter"
      ~ regions                 = [
          - "Datacenter:datacenter-488",
            "Datacenter:datacenter-58",
          + "Datacenter:datacenter-488",
        ]
        # (14 unchanged attributes hidden)
    }

  # module.vra-tf-eisre-infra.vra_zone.bedford_zone will be updated in-place
  ~ resource "vra_zone" "bedford_zone" {
        id                 = "6dc9a216-d5ac-410b-9f45-507e3e6019e1"
        name               = "Bedford vCenter / Bedford"
      ~ region_id          = "d9ccd787-05e1-4f3b-9dc1-ed325a4d5741" -> (known after apply)
        # (8 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # module.vra-tf-eisre-infra.vra_zone.belfast_zone will be updated in-place
  ~ resource "vra_zone" "belfast_zone" {
        id                 = "384b3743-2f16-4622-b146-d47aeb563e36"
        name               = "Bedford vCenter / Belfast"
      ~ region_id          = "d3b54716-b69f-4e36-a97d-287c1448df00" -> (known after apply)
        # (9 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 3 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.vra-tf-eisre-infra.vra_cloud_account_vmc.bedford_vcenter: Modifying... [id=37eabfeb-df3e-4b64-84cf-791adc435684]
module.vra-tf-eisre-infra.vra_cloud_account_vmc.bedford_vcenter: Modifications complete after 5s [id=37eabfeb-df3e-4b64-84cf-791adc435684]
module.vra-tf-eisre-infra.data.vra_region.belfast_region: Reading... [id=d3b54716-b69f-4e36-a97d-287c1448df00]
module.vra-tf-eisre-infra.data.vra_region.bedford_region: Reading... [id=d9ccd787-05e1-4f3b-9dc1-ed325a4d5741]
module.vra-tf-eisre-infra.data.vra_region.belfast_region: Read complete after 1s [id=d3b54716-b69f-4e36-a97d-287c1448df00]
module.vra-tf-eisre-infra.data.vra_region.bedford_region: Read complete after 1s [id=d9ccd787-05e1-4f3b-9dc1-ed325a4d5741]

Steps to Reproduce

  1. terraform apply

Debug Output

https://gist.github.com/rnelson0/585c95ed8090bdfa309a861fc9f7b417

Important Factoids

I tried doing terraform state rm ; terraform import of the vcenter object and the regions still show 488 before 58 and attempt to swap that during apply, with no change in the state.

@rnelson0 rnelson0 added bug Bug needs-triage Needs Triage labels Sep 17, 2021
@frodenas
Copy link
Member

This is similar to #358

@rnelson0
Copy link
Contributor Author

rnelson0 commented Sep 20, 2021

Thanks @frodenas, feel free to mark this as duplicate. I'll put updates in the other ticket, then test and close this out if it proves to be the same thing.

@frodenas frodenas added duplicate Duplicate and removed needs-triage Needs Triage labels Oct 22, 2021
@frodenas
Copy link
Member

@rnelson0 Thanks for submitting this bug. I'm going to close it as this is a duplicate of #358. Please reopen if you think this is not the case.

@vmware vmware locked and limited conversation to collaborators Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug duplicate Duplicate
Projects
None yet
Development

No branches or pull requests

2 participants