azure_policy_exemption Resource
Use the azure_policy_exemption
InSpec audit resource to test properties related to a Azure Policy Exemption.
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
describe azure_policy_exemption(resource_group: 'RESOURCE_GROUP', name: 'POLICY_EXEMPTION_NAME') do
it { should exist }
its('name') { should cmp '3b8b3f3bbec24cd6af583694' }
its('type') { should cmp 'Microsoft.Authorization/policyExemptions' }
its('properties.exemptionCategory') { should cmp 'Waiver' }
its('properties.policyAssignmentId') { should cmp '/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement' }
its('systemData.createdByType') { should cmp 'User' }
end
describe azure_policy_exemption(name: 'POLICY_EXEMPTION_NAME') do
it { should exist }
end
Parameters
name
(required)-
The name of the Azure Policy Exemption to test.
resource_group
(optional)-
The name of the resource group.
Properties
id
- Resource ID.
name
- Policy Exemption Name.
type
- Resource type.
properties.policyAssignmentId
- The ID of the policy assignment that is being exempted.
properties.policyDefinitionReferenceIds
- The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition.
properties.exemptionCategory
- The policy exemption category. Possible values are Waiver and Mitigated.
properties.displayName
- The display name of the policy exemption.
properties.description
- The description of the policy exemption.
systemData.createdBy
- The identity that created the resource.
For properties applicable to all resources, such as type
, name
, id
, properties
, refer to azure_generic_resource
.
Also, refer to Azure documentation for other properties available.
Any attribute in the response may be accessed with the key names separated by dots (.
).
Examples
Test that the policy exemption category is Waiver
.
describe azure_policy_exemption(name: 'POLICY_EXEMPTION_NAME') do
its('properties.exemptionCategory') { should eq 'Waiver' }
end
Test that the definition reference ID list includes a particular reference ID.
describe azure_policy_exemption(resource_group: 'RESOURCE_GROUP', name: 'POLICY_EXEMPTION_NAME') do
its('properties.policyDefinitionReferenceIds') { should include 'POLICY_DEFINITION_REFERENCE_ID' }
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
# If a policy exemption is found it will exist
describe azure_policy_exemption(name: 'POLICY_EXEMPTION_NAME') do
it { should exist }
end
# policy exemptions that aren't found will not exist
describe azure_policy_exemption('3b8b3f3bbec24cd6af583694') do
it { should_not exist }
end
Azure Permissions
Your Service Principal must be set up with at least a contributor
role on the subscription you wish to test.
Was this page helpful?