vmware / terraform-provider-vra

Terraform Provider for VMware Aria Automation
https://registry.terraform.io/providers/vmware/vra/
Mozilla Public License 2.0
103 stars 92 forks source link

Subsequent terraform apply fails in vra_cloud_account_vsphere due to dcid #474

Closed whochradel closed 1 year ago

whochradel commented 2 years ago

Code of Conduct

This project has a Code of Conduct that all participants are expected to understand and follow:

vRA Version

vRA Cloud

Terraform Version

v1.3.2

vRA Terraform Provider Version

v0.6.0

Affected Resource(s)

vra_cloud_account_vsphere

Terraform Configuration Files

terraform { required_providers { vra = { source = "vmware/vra" } } }

provider "vsphere" { user = var.vmw_username password = var.vmw_password vsphere_server = var.vmw_hostname allow_unverified_ssl = true }

data vsphere_datacenter "this" { for_each = toset(var.vmw_region_name) name = each.value }

// Required for vRA Cloud, Optional for vRA 8.X

data "vra_data_collector" "this" { count = var.data_collector_name != "" ? 1 : 0 name = var.data_collector_name }

resource "vra_cloud_account_vsphere" "this" { name = var.vmw_cloud_account_name description = var.vmw_cloud_account_description hostname = var.vmw_hostname username = var.vmw_username password = var.vmw_password regions = [for v in data.vsphere_datacenter.this: format("Datacenter:%s", v.id)] accept_self_signed_cert = true associated_cloud_account_ids = [var.associated_cloud_account_ids]

// Required for vRA Cloud, Optional for vRA 8.X dc_id = var.data_collector_name != "" ? data.vra_data_collector.this[0].id : ""

tags { key = "platform" value = "vsphere" } tags { key = "cloud type" value = "private" } }

Expected Behavior

Once created, a rerun of main configuration would detect no changes

Actual Behavior

When specifing the dc_id it appears to write the value to dcid. Unfortunately a rerun of terraform sees dc_id as empty and recogizes a change. Subsequent runs fail.

Steps to Reproduce

  1. terraform apply
  2. terraform apply (second run fails everytime)

Screenshots

Screenshot 2022-10-27 at 9 12 25 AM

Community Note