microsoft / microsoft/finops-toolkit
[PowerShell] Get-FinOpsHub – Get all resources based on name
Open
@arthurclares is already working on this.
Since Oct 26, 2023.
Tool: FinOps hubs
Tool: PowerShell
- Dominant language
- PowerShell
- Stars
- 603
- Forks
- 248
- Avg merge
- 7d 11h
- Merged PRs (30d)
- 11
Description
📝 Scenario
As a hub admin, I need to get metadata about a hub instance with all dependant resources in order to manage delete all resources
💎 Solution
Update Get-FinOpsHub command to get all related resources.
Synopsis, syntax, description, and parameters stay the same. The only thing that changes is the output.
ℹ️ Additional info
Use the following code to get any addtional resources that were not identified via the tag:
$kv = $hub.Resources | Where-Object ResourceType -eq "Microsoft.KeyVault/vaults"
$uniqueId = $kv[0].Substring($kv[0].LastIndexOf("-") + 1)
$resources = Get-AzResource -ResourceGroupName $ResourceGroup | Where-Object Name -like "*$uniqueId*"
The output object should look this:
{
// ID is added as a cm-resource-parent tag to all deployed resources as part of the bicep code
Id: "/subscriptions/.../resourceGroups/.../providers/Microsoft.Cloud/hubs/...",
// Type and name can be parsed out of the ID
Type: "Microsoft.Cloud/hubs",
Name: "...",
// Location would be pulled from the resources
Location: "...",
// Version pulled from settings.json
Version: "0.0.1",
// Resources determined at runtime via tags or with the unique deployment id in the name
Resources: [
{ ... },
{ ... },
{ ... },
...
],
}
🙋♀️ Ask for the community
We could use your help:
- Please vote this issue up (👍) to prioritize it.
- Leave comments to help us solidify the vision.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.