Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Ability to inject custom tags #4479

Open
seesharprun opened this issue Oct 23, 2024 · 4 comments
Open

[FEATURE REQUEST] Ability to inject custom tags #4479

seesharprun opened this issue Oct 23, 2024 · 4 comments
Labels
discuss feature needs-team-attention Issues out of a milestone needs-triage For new issues

Comments

@seesharprun
Copy link

Ask

It would be amazing to have a way to set an environment variable in your dev environment with a list of custom tags that you want applied to any AZD deployment. It would be even better if there's a way to do this without modifying existing templates.

Context

It's not uncommon to have requirements on your Azure subscription to tag your deployments with metadata like:

created-by:<your-principal>
deployment-type:<automated>
<something-else>:<some-value>

Today, I need to modify any AZD template I pull down to add this functionality.

In a perfect world, I could have either an environment variable or some special *.env file (bonus points for recursive lookup) where I can define custom tags that should be applied to any AZD deployment I create.

Research

I searched the documentation and this repository to see if someone has brought this up before. If I missed another issue, I apologize.

@jongio
Copy link
Member

jongio commented Oct 23, 2024

Do you need those tags apply to each individual resource within that deployment? You'd be great if you could show (in detail) what you do today, just to make sure that whatever we implement addresses that scenario.

@seesharprun
Copy link
Author

I've been asked to do both before by different people as a way to track costs in Azure subscriptions.

  • Apply a tag like created-by: <alias> to all resources within a resource group to help a manager visualize costs in a shared subscription by team member
  • Apply a tag like automation: true to resource groups so it's known it was created by automation and not by person.

In reality, I'm asked to create tags for a myriad of reasons. In my own AZD templates, I can accomplish it today by manually editing the template and adding more content to the var tags. Unfortunately, this is a var in most templates so there's really no way to say, for example "anytime I deploy an AZD template, apply the created-by: seesharprun to all resources/or and the resource group."

Today, I accomplish this by running this type of command in PowerShell using Azure CLI:

az group update --resource-group "<resource-group-name>" --tags "key=value"

foreach ($resource in (az resource list --resource-group "<resource-group-name>" | ConvertFrom-Json)) { 
  az resource tag --is-incremental --resource-group "<resource-group-name>" --name $resource.name --resource-type $resource.type --tags "key=value" 
}

In a perfect world, I could have some type of environment file either in the template directory or a parent directory (think like .vscode settings) where I can configure some resource-group, subscription, or resource level auto-tags to apply.

This is SUPER low priority, but I just thought I would put it on your radar since today I'm tagging things manually after running the AZD deployment. Please feel free to push this to the back of your backlog 😄

@vhvb1989
Copy link
Member

Could this be a potential candidate for an extension @wbreza ?

I think something like azd tag-resources .... where folks can:

  • define their own ENV VARS or input files for adding tags to the resources created by azd.

azd would provide the library to get the list of resources and apply tags.

The only downside would be that calling provision would re-set all tags to what is defined in bicep, so the extension would need to become a postprovision hook to keep the state.

@seesharprun
Copy link
Author

Extensions/plugins would solve this for me. I know that work is planned in #3565

@wbreza wbreza added the needs-triage For new issues label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss feature needs-team-attention Issues out of a milestone needs-triage For new issues
Projects
None yet
Development

No branches or pull requests

4 participants