azure_policy_exemptions Resource
Use the azure_policy_exemptions InSpec audit resource to test properties related to all Azure Policy Exemptions for the subscription.
Azure REST API Version, Endpoint, and HTTP Client Parameters
This resource interacts with API versions supported by the resource provider.
The api_version can be defined as a resource parameter.
If not provided, this resource uses the latest version.
For more information, refer to the azure_generic_resource document.
Unless defined, this resource uses the azure_cloud global endpoint and default values for the HTTP client.
For more information, refer to the resource pack README.
Installation
This resource is available in the Chef InSpec Azure resource pack.
See the Chef InSpec documentation on cloud platforms for information on configuring your Azure environment for InSpec and creating an InSpec profile that uses the InSpec Azure resource pack.
Syntax
An azure_policy_exemptions resource block returns all Azure Policy Exemptions within a Subscription.
describe azure_policy_exemptions do
#...
end
Parameters
Properties
ids- A list of the unique resource ids.
Field:
idnames- A list of names for all the Resources.
Field:
nametypes- A list of types for all the resources.
Field:
typeproperties- A list of Properties all the resources.
Field:
propertiessystem_data- A list of System Data for all the resources.
Field:
system_datapolicy_assignment_ids- A list of Policy Assignment IDs.
Field:
policy_assignment_idpolicy_definition_reference_ids- A list of Policy Definition Reference Ids.
Field:
policy_definition_reference_idsexemption_categories- A list of categories of Exemptions.
Field:
exemption_categorydisplay_names- A list of display names of the Exemptions.
Field:
display_namedescriptions- A list of descriptions of the Exemptions. .
Field:
descriptionmetadata- A list of metadata info of the Exemptions.
Field:
metadatacreated_by- A list of creators of the exemptions.
Field:
created_bycreated_by_types- A list of type of creators of the exemptions.
Field:
created_by_typecreated_at- A list of created_at timestamps of the exemptions.
Field:
created_atlast_modified_by- A list of last modifiers of the exemptions.
Field:
last_modified_bylast_modified_by_types- A list of type of the modifiers of the exemptions.
Field:
last_modified_by_typelast_modified_at- A list of modified_at timestamps of the exemptions.
Field:
last_modified_at
Note
See the documentation on FilterTable for information on using filter criteria on plural resources.
Examples
Loop through Policy Exemptions by Their Names.
azure_policy_exemptions.names.each do |name|
describe azure_policy_exemption(name: name) do
it { should exist }
end
end
Test that There are Policy Exemptions that are of waiver exemption category .
describe azure_policy_exemptions.where(exemption_category: 'Waiver') do
it { should exist }
end
Matchers
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our Universal Matchers page.
exists
# Should not exist if no policy exemptions are present in the subscription
describe azure_policy_exemptions do
it { should_not exist }
end
# Should exist if the filter returns at least one policy exemption in the subscription
describe azure_policy_exemptions do
it { should exist }
end
Azure Permissions
Your Service Principal must be set up with at least a contributor role on the subscription you wish to test.