Closed sandkum5 closed 1 month ago
@sandkum5
Have you tested using the additional_attributes = jsonencode(filter = "Organization/Moid eq '${data.intersight_organization_organization.org.results[0].moid}')
Bumping this, the filter
parameter doesn't seem to be present on any data sources I've spot-checked so far. additional_attributes
isn't a supported parameter on any of them either. I've tested with:
intersight_network_element
intersight_asset_device_registration
intersight_resource_group_member
Tested with latest 1.0.46
release@cwilloughby-bw & @sandkum5 Although you can't use the filter on the data object you can parse the data when it comes back to do a comparison to figure out the Correct organization.
I have accomplished in two different methods. One like this:
moid = contains(keys(lookup(local.policies, policy_bucket.value.policy, {})), "${policy_bucket.value.org}/${policy_bucket.value.name}"
) == true ? local.policies[policy_bucket.value.policy]["${policy_bucket.value.org}/${policy_bucket.value.name}"
] : [for i in data.intersight_search_search_item.policies[policy_bucket.value.policy
].results : i.moid if jsondecode(i.additional_properties).Name == policy_bucket.value.name && jsondecode(i.additional_properties
).Organization.Moid == var.orgs[policy_bucket.value.org]][0]
The other method that I have recently come back to is compiling the data in locals and making the key of the object to include the organization and look it up that way. i.e.
policies_data = { for k in keys(data.intersight_search_search_item.policies) : k => {
for e in lookup(data.intersight_search_search_item.policies[k], "results", []
) : "${local.org_names[jsondecode(e.additional_properties).Organization.Moid]}/${jsondecode(e.additional_properties).Name}" => merge({
additional_properties = jsondecode(e.additional_properties)
moid = e.moid
})
} }
Now when I look it up in policy_bucket it is much easier to use.
moid = contains(keys(lookup(local.policies, policy_bucket.value.policy, {})), policy_bucket.value.name
) == true ? local.policies[policy_bucket.value.policy][policy_bucket.value.name] : local.policies_data[policy_bucket.value.policy][policy_bucket.value.name].moid
object_type = policy_bucket.value.object_type
Hi @sandkum5 , We can achieve the operation requested by you in follow example mentioned below, This works with latest terraform version.
For intersight_softwarerepository_catalog
data "intersight_organization_organization" "organization" {
name = "default"
}
data "intersight_softwarerepository_catalog" "sw_catalog" {
organization {
moid = data.intersight_organization_organization.organization.id
}
name = "user-catalog"
}
For intersight_firmware_server_configuration_utility_distributable
Organization can be associated with Software repository by selecting a catalog under required organization. In hierarchy of relationship of Software repository with Organization is that Software Repository has relationship with Catalog which in turns has relationship with Organization.
data "intersight_organization_organization" "organization" {
name = "default"
}
data "intersight_softwarerepository_catalog" "catalog"{
organization {
class_id = "organization.Organization"
moid = data.intersight_organization_organization.organization.id
}
}
data "intersight_firmware_server_configuration_utility_distributable" "scufilter" {
name = "SCU-6.0.4c nfs"
catalog {
moid = data.intersight_softwarerepository_catalog.catalog.results[0].moid
object_type = "softwarerepository.Catalog"
}
}
This issue is fixed in latest release(1.0.56). The association of organization SCU is also mentioned in the comments. Please try and let us know. Closing the issue now. If bug persists please re-open the issue.
Description
Data Source "intersight_softwarerepository_catalog" doesn't have a filter argument.
When we are creating repos using Terraform, we need to select the catalog from the right organization.
Hence, filtering the output is kind of a necessity to use it under the resources
intersight_firmware_server_configuration_utility_distributable
,intersight_softwarerepository_operating_system_file
.Terraform-provider-intersight version
❯ terraform providers -version Terraform v1.4.6 on darwin_arm64