Description
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"
}
}