An Azure tags checking tool that can be used to look for untagged resources, missing tags, resources with too many tags, and more.
- Download and install Steampipe (https://steampipe.io/downloads). Or use Brew:
brew tap turbot/tap
brew install steampipe
steampipe -v
steampipe version 0.8.0
- Install the Azure plugin:
steampipe plugin install azure
- Clone this repo:
git clone https://github.com/turbot/steampipe-mod-azure-tags.git
cd steampipe-mod-azure-tags
Preview running all benchmarks:
steampipe check all --dry-run
Run all benchmarks:
steampipe check all
Use Steampipe introspection to view all current benchmarks:
steampipe query "select resource_name, title, description from steampipe_benchmark;"
Run an individual benchmark:
steampipe check benchmark.untagged
Use Steampipe introspection to view all current controls:
steampipe query "select resource_name, title, description from steampipe_control;"
Run a specific control:
steampipe check control.compute_virtual_machine_untagged
Several benchmarks have input variables that can be configured to better match your environment and requirements. Each variable has a default defined in steampipe.spvars
, but these can be overriden in several ways:
- Modify the
steampipe.spvars
file - Remove or comment out the value in
steampipe.spvars
, after which Steampipe will prompt you for a value when running a query or check - Pass in a value on the command line:
steampipe check benchmark.mandatory --var 'mandatory_tags=["Application", "Environment", "Department", "Owner"]'
- Set an environment variable:
SP_VAR_mandatory_tags='["Application", "Environment", "Department", "Owner"]' steampipe check control.compute_virtual_machine_mandatory
- Note: When using environment variables, if the variable is defined in
steampipe.spvars
or passed in through the command line, either of those will take precedence over the environment variable value. For more information on variable definition precedence, please see the link below.
- Note: When using environment variables, if the variable is defined in
These are only some of the ways you can set variables. For a full list, please see Passing Input Variables.
Using the control output and the Azure CLI, you can remediate various tagging issues.
For instance, with the results of the compute_virtual_machine_mandatory
control, you can add missing tags with the Azure CLI:
#!/bin/bash
OLDIFS=$IFS
IFS='#'
INPUT=$(steampipe check control.compute_virtual_machine_mandatory --var 'mandatory_tags=["Application"]' --output csv --header=false --separator '#' | grep 'alarm')
[ -z "$INPUT" ] && { echo "No virtual machines in alarm, aborting"; exit 0; }
while read -r group_id title description control_id control_title control_description reason resource status resource_group subscription
do
az tag create --resource-id ${resource} --tags Application=MyApplication
done <<< "$INPUT"
IFS=$OLDIFS
To remove prohibited tags from Compute virtual machines:
#!/bin/bash
OLDIFS=$IFS
IFS='#'
INPUT=$(steampipe check control.compute_virtual_machine_prohibited --var 'prohibited_tags=["Password"]' --output csv --header=false --separator '#' | grep 'alarm')
[ -z "$INPUT" ] && { echo "No virtual machines in alarm, aborting"; exit 0; }
while read -r group_id title description control_id control_title control_description reason resource status resource_group subscription
do
az tag delete --resource-id ${resource} --name Password --yes
done <<< "$INPUT"
IFS=$OLDIFS
If you have an idea for additional tags controls, or just want to help maintain and extend this mod (or others) we would love you to join the community and start contributing. (Even if you just want to help with the docs.)
- Join our Slack community → and hang out with other Mod developers.
- Mod developer guide →
Please see the contribution guidelines and our code of conduct. All contributions are subject to the Apache 2.0 open source license.
help wanted
issues: