finops-toolkit icon indicating copy to clipboard operation
finops-toolkit copied to clipboard

[PowerShell] Add-FinOpsHubScope (0.0.1)

Open flanakin opened this issue 2 years ago â€ĸ 2 comments

📝 Scenario

As a hub admin, I need to add scopes to a hub instance in order to start monitoring a new scope

💎 Solution

Create an Add-FinOpsHubScope function to create exports and optionally back-fill data.

Synopsis

Starts monitoring a scope within a FinOps hub instance.

Syntax

Add-FinOpsHubScope `
    [-Id] <string> `
    -HubName <string> `
    [-Backfill]

Description

The Add-FinOpsHubScope cmdlet adds a scope to be monitored by a FinOps hub instance. By default, this will start only start pulling data for the current month, which should be available within 30 minutes. To import historical data, use the -Backfill option.

Parameters

Parameter Description
-Id Required. Resource ID of the scope to remove.
-HubName Required. Name of the hub instance to update.
-Backfill Optional. Indicates whether to remove data for this scope from storage. Default = false.

â„šī¸ Additional info

In 0.0.1, exports are managed manually. When the command is called, run the following:

$hub = Get-FinOpsHub -Name $HubName
# Validate there's only 1 hub returned
New-FinOpsCostExport `
  -Name "$HubName-monthly-AmortizedCost" `
  -Scope $Id `
  -DataSet AmortizedCost `
  -StorageAccountId $hub.properties.resources.storage `
  -StorageContainer msexports `
  -StoragePath $Id.Trim("/") `
  -Execute `
  -Backfill 13

đŸ™‹â€â™€ī¸ Ask for the community

We could use your help:

  1. Please vote this issue up (👍) to prioritize it.
  2. Should this be Add-FinOpsHubScope or New-FinOpsHubScope?
  3. Do we want to specify the scope as a single parameter (-Id) or multiple (-Subscription "..." -ResourceGroup "...") or support both?
  4. How should we identify the hub instance? Do we have enough parameters?
  5. Should we support adding multiple scopes at one time?
  6. Are there any parameters that are missing?
  7. Leave comments to help us solidify the vision.

flanakin avatar Aug 15 '23 01:08 flanakin

@sebassem I'm picking this one up as I know you are busy with the Workbook PR. I will sync with you offline to see where you are.

arthurclares avatar Oct 06 '23 09:10 arthurclares

@akiskips

arthurclares avatar May 15 '24 10:05 arthurclares

In response to the "đŸ™‹â€â™€ī¸ Ask for the community" questions...

  1. Should this be Add-FinOpsHubScope or New-FinOpsHubScope?
  • To align more naturally with the Remove-FinOpsHubScope command, my vote is for Add-FinOpsHubScope.
  1. Do we want to specify the scope as a single parameter (-Id) or multiple (-Subscription "..." -ResourceGroup "...") or support both?
  • More options are better, as it provides maximum flexibility.
  1. Should we support adding multiple scopes at one time?
  • Yes, absolutely! Support a list or an array of scopes to add.

AErmie avatar Oct 23 '24 19:10 AErmie