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.
You can specify the api_version
as a resource parameter to use a specific version of the Azure REST API.
If you don’t specify an API version, this resource uses the latest version available.
For more information about API versioning, see the azure_generic_resource
.
By default, this resource uses the azure_cloud
global endpoint and default HTTP client settings.
You can override these settings if you need to connect to a different Azure environment (such as Azure Government or Azure China).
For more information about configuration options, see the resource pack README.
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:
id
names
- A list of names for all the resources.
Field:
name
types
- A list of types for all the resources.
Field:
type
properties
- A list of properties for all the resources.
Field:
properties
system_data
- A list of System Data for all the resources.
Field:
system_data
policy_assignment_ids
- A list of Policy Assignment IDs.
Field:
policy_assignment_id
policy_definition_reference_ids
- A list of Policy Definition Reference IDs.
Field:
policy_definition_reference_ids
exemption_categories
- A list of categories of exemptions.
Field:
exemption_category
display_names
- A list of display names of the exemptions.
Field:
display_name
descriptions
- A list of descriptions of the exemptions.
Field:
description
metadata
- A list of metadata info of the exemptions.
Field:
metadata
created_by
- A list of creators of the exemptions.
Field:
created_by
created_by_types
- A list of the type of creators of the exemptions.
Field:
created_by_type
created_at
- A list of created_at timestamps of the exemptions.
Field:
created_at
last_modified_by
- A list of the last modifiers of the exemptions.
Field:
last_modified_by
last_modified_by_types
- A list of the type of modifiers of the exemptions.
Field:
last_modified_by_type
last_modified_at
- A list of
modified_at
timestamps of the exemptions.Field:
last_modified_at
Note
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
For a full list of available matchers, see our Universal Matchers page.This resource has the following special matchers.
not_exists
# Should not exist if no policy exemptions are present in the subscription.
describe azure_policy_exemptions do
it { should_not exist }
end
exists
# 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.