Skip to main content

azure_dns_zones_resource resource

Use the azure_dns_zones_resource InSpec audit resource to test the properties of an Azure DNS zone.

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

This resource requires either the resource_group, and DNS zone resource name or the resource_id.

describe azure_dns_zones_resource(resource_group: 'RESOURCE_GROUP_NAME', name: 'DNS_ZONE_NAME') do
  it { should exist }
end

Or

describe azure_dns_zones_resource(resource_id: 'DNS_ZONE_RESOURCE_ID') do
  it { should exist }
end

Parameters

resource_group
Azure resource group where the targeted resource resides.
name
Name of the DNS zone to test.
resource_id
The resource ID of the DNS zone to test.

The resource_group and name, or the resource_id are required parameters.

Properties

name
Name of the Azure resource to test.
type
The type of DNS zone.
max_number_of_recordsets
The maximum number of record sets that can be created in this DNS zone.
number_of_record_sets
The current number of record sets in this DNS zone.
name_servers
The name servers for this DNS zone.
properties
The properties of the Azure DNS zone resource.
location
The DNS zone resource location.

Also, refer to the Azure documentation for other available properties. You can access any attribute in the response with the key names separated by dots (.).

Examples

Test that the Azure DNS zone resource has the correct resource type:

describe azure_dns_zones_resource(resource_group: 'RESOURCE_GROUP_NAME', name: 'DNS_ZONE_NAME') do
  its('type') { should eq 'Microsoft.Network/dnszones' }
end

Test that the location of the Azure DNS zone resource is ‘global’:

describe azure_dns_zones_resource(resource_group: 'RESOURCE_GROUP_NAME', name: 'DNS_ZONE_NAME') do
  its('location') { should eq 'global' }
end

Matchers

For a full list of available matchers, see our Universal Matchers page.

exists

# If a DNS Zone resource is found, it will exist.

describe azure_dns_zones_resource(resource_group: 'RESOURCE_GROUP_NAME', name: 'DNS_ZONE_NAME') do
  it { should exist }
end

# DNS Zone resources that aren't found, will not exist.

describe azure_dns_zones_resource(resource_group: 'RESOURCE_GROUP_NAME', name: 'DNS_ZONE_NAME') 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.

Thank you for your feedback!

×