vmware / terraform-provider-vra

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

Add support for manageability of multiple storage profiles #335

Open brude-softserve opened 3 years ago

brude-softserve commented 3 years ago

vRA version v8 Terraform version v0.14.9 terraform-provider-vra plugin version v0.3.5

Is your feature request related to a problem? Please describe. Current examples of storage profiles show only a single-profile use-case while in real environments it's needed to manage multiple storage profiles. Each storage profile relies on the vra_fabric_datastore_vsphere and vra_fabric_storage_policy_vsphere data sources so you need to keep track of three different loops and create some connections between them which makes the code heavier and more error-prone. For example, this is the workaround we have to use:

data "vra_fabric_datastore_vsphere" "this" {
  for_each = {
    for key, profile in var.storage_profiles :
    key => profile
    if profile.datastore != "Any"
  }
  filter = "name eq '${each.value.datastore}'"
}
data "vra_fabric_storage_policy_vsphere" "this" {
  for_each = {
    for key, profile in var.storage_profiles :
    key => profile
    if profile.storage_policy != "Default"
  }
  filter = "name eq '${each.value.storage_policy}'"
}
resource "vra_storage_profile" "this" {
  for_each    = var.storage_profiles
  name        = each.key
  description = "Storage Profile"
  region_id = var.region_id
  default_item = each.value.default
  disk_properties = each.value.disk_properties
  disk_target_properties = {
    datastoreId     = each.value.datastore != "Any" ? data.vra_fabric_datastore_vsphere.this[each.key].id : null
    storagePolicyId = each.value.storage_policy != "Default" ? data.vra_fabric_storage_policy_vsphere.this[each.key].id : null
  }
}

Describe the solution you'd like It would be great if it was possible to set the datastore name and policy within the vra_storage_profile resource definition, for example:

resource "vra_storage_profile" "this" {
  name        =  "storage_profile1"
  description = "Storage Profile 1"
  region_id = var.region_id
  default_item = true
  disk_properties = { 
      provisioningType = "thin"
  }
  disk_target_properties = {
    datastoreName     =  "datastore-1"
    storagePolicyName = "Default"
  }
}
github-actions[bot] commented 3 years ago

Marking this issue as stale due to inactivity. This helps us focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!