microsoft / finops-toolkit

Tools and resources to help you adopt and implement FinOps capabilities that automate and extend the Microsoft Cloud.
https://aka.ms/finops/toolkit
MIT License
282 stars 91 forks source link

[PowerShell] Get-FinOpsHub (0.3) #236

Open flanakin opened 1 year ago

flanakin commented 1 year ago

πŸ“ Scenario

As a hub admin, I need to get hub metadata in order to confirm the hub is setup correctly

πŸ’Ž Solution

Update the Get-FinOpsHub command to include new settings and resources in 0.3.

β›” Blocked

  • Sync features/exports into dev, then into features/powershell

Synopsis, syntax, description, and parameters should not change. We only need to update the output.

{
  // 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: "...",
  properties: {
    // Version, retention, and scopes pulled from settings.json
    version: "0.3",
    retention: {
      ingestion: {
        months: 13,
      },
      msexports: {
        days: 0,
      },
    },
    scopes: [{
      scope: "...",
    }],

    // Resources determined at runtime via tags or saved in settings.json (TBD)
    resources: {
      dataFactory: "<data-factory-id>",
      keyVault: "<keyvault-id>",
      storage: "<storage-account-id>",
      ...
    },
  }
  }
}

πŸ™‹β€β™€οΈ Ask for the community

We could use your help:

  1. Please vote this issue up (πŸ‘) to prioritize it.
  2. Are there any parameters that are missing?
  3. Leave comments to help us solidify the vision.
erose96 commented 5 months ago

Would this work item cause this Cmdlet to return the latest deployed version of the template? Currently when I run this, I get this for the version return:

Version   : 0.1

However, I have deployed the 0.3 version and have verified the version by checking the tag on the storage account (+ I have seen the changes implemented in the 0.3 version of the hub).

My use case: writing a deployment pipeline for updating the finops hub version, would be useful to use the Get Cmdlet to check what version is already deployed.

erose96 commented 5 months ago

Reviewing the code, I think the first if statement should check for the existence of the ftk-version tag and then if it matches across all of the resources it gets applied to, set the value of $version to the tag value.