microsoft / microsoft/finops-toolkit
Apply tags to Resource Group during Hubs deployment
Open
@ymehdimsft is already working on this.
Since Mar 13, 2024.
Skill: Deployment
Tool: FinOps hubs
- Dominant language
- PowerShell
- Stars
- 603
- Forks
- 248
- Avg merge
- 7d 11h
- Merged PRs (30d)
- 11
Description
📝 Scenario
The Deploy to Azure button for FinOps Hubs presents the Azure portal tab to set Tags, but these only get applied to the Resources, not the Resource Group, even if you create a new RG as part of the deployment.
💎 Solution
Add a step to retrofit the tags to the RG too (new or existing), after it has been created.
ℹ️ Additional context
In order to do this, we'll need to update the following:
- Add "Microsoft.Resources/resourceGroups" to the list of taggable resources in
src/templates/finops-hub/createUiDefinition.json - In
src/templates/finops-hub/modules/hub.bicep, create a new deployment script that tags the resource group- Add a new section under Key Vault that includes a new managed identity, role assignment, and deployment script (you can copy what's in storage.bicep)
- Assign the Resource Group Contributor role to the managed identity
- Pass the tags in as an environment variable:
contains(tagsByResource, 'Microsoft.Resources/resourceGroups') ? tagsByResource['Microsoft.Resources/resourceGroups'] : {}) - Create a script in
src/templates/finops-hub/modules/scripts/Tag-ResourceGroup.ps1 - In the script, check to see if there is a tag to add and don't do anything if there isn't
- Update the
docs/finops-hub/template.mdfile:- Add a note about the Resource Group Contributor access being required only if a resource group tag is applied in the
tagsByResourcevariable. - Could you also add the
tagsByResourceparameter to the Parameters section? Get the description from hub.bicep. - Add the managed identity to the list.
- Add a note about the Resource Group Contributor access being required only if a resource group tag is applied in the
- Don't forget to update
docs/changelog.md
To test, run the local deployment script from PowerShell:
. src/scripts/Deploy-Toolkit.ps1 finops-hub -Build
🙋♀️ 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.