Project: Chef InSpec (Provisioning / Security & Compliance)
File: azurerm_resource_groups.md

+++ title = "azurermresourcegroups resource" draft = false gh_repo = "inspec" platform = "azure" [menu] [menu.inspec] title = "azurermresourcegroups" identifier = "inspec/resources/azure/azurermresourcegroups.md azurermresourcegroups resource" parent = "inspec/resources/azure" +++ {{< inspec/azurermdeprecated resource="azureresource_groups" >}} Use the `azurermresourcegroups` InSpec audit resource to test properties of some or all Azure Resource Groups A Resource Group is a grouping of Azure resources. This allows you to issue a common command on a group of resources. This resource interacts with version `2018-02-01` of the Azure Management API. For more information see the [official Azure documentation](https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups/list). At the moment, there doesn't appear to be a way to select the version of the Azure API docs. If you notice a newer version being referenced in the official documentation please open an issue or submit a pull request using the updated version. This resource is available in the `inspec-azure` [resource pack](/inspec/glossary/#resource-pack). To use it, add the following to your `inspec.yml` in your top-level profile: depends: name: inspec-azure git: https://github.com/inspec/inspec-azure.git You'll also need to setup your Azure credentials; see the resource pack . This resource first became available in 1.0.0 of the inspec-azure resource pack. An `azurermresourcegroups` resource block uses an optional filter to select a group of Resource Groups and then tests that group. describe azurermresourcegroups do ... end The following examples show how to use this InSpec audit resource. describe azurermresourcegroups do its('names') { should include 'MyResourceGroup' } end describe azurermresourcegroups.where(name: 'MyResourceGroup') it { should exist } end azurermresourcegroups.names.each do |resource_group| describe azurermvirtualmachines(resourcegroup: resourcegroup, name: 'MyVmName') do its('monitoringagentinstalled') { should be true } end end `names` Filters the results to include only those resource groups that match the given name. This is a string value. describe azurermresourcegroups.where { name.start_with?('InSpec') } do it { should exist } end `ids` `names` `tags` The ids property provides a list of all the Resource Group ids. its('ids') { should include 'MyResourceGroupID' } The names property provides a list of all the Resource Group names. its('names') { should include 'MyResourceGroup' } The tags property provides a list of all the Resource Group tags. its('tags') { should include '{MyResourceGroupTag=""}' } {{< readfile file="content/inspec/reusable/md/inspecmatcherslink.md" >}} This resource has the following special matchers. The control will pass if the filter returns at least one result. Use `should_not` if you expect zero matches. describe azurermresourcegroups do it { should exist } end Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be setup with a `contributor` role on the subscription you wish to test.