Skip to main content

azure_ddos_protection_resource resource

Use the azure_ddos_protection_resource InSpec audit resource to test the properties of a DDoS protection plan resource.

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

The resource_group and the DDoS protection plan resource name, or the resource_id are required parameters.

describe azure_ddos_protection_resource(resource_group: 'RESOURCE_GROUP', name: 'DDOS_PROTECTION_PLAN_NAME') do
  it { should exist }
end

Parameters

NameDescription
resource_groupAzure resource group where the targeted resource resides.
nameName of the Azure DDoS protection plan resource to test.
resource_idThe Azure DDoS protection plan resource ID to test.

Properties

name
Name of the Azure DDoS protection plan resource to test.
type
The resource type.
provisioning_state
The provisioning state of the DDoS protection plan. Valid values: Deleting, Failed, Succeeded, and Updating.
virtual_networks
The list of virtual networks associated with the DDoS protection plan resource.
resource_guid
The resource GUID property of the DDoS protection plan resource. It uniquely identifies the resource, even if the user changes its name or migrates the resource across subscriptions or resource groups.

Also, refer to the Azure documentation for other properties available. Access any attribute in the response by separating the key names with a period (.).

Examples

Test to ensure that the DDoS protection plan resource has the correct type:

describe azure_ddos_protection_resource(resource_group: 'RESOURCE_GROUP', name: 'DDOS_PROTECTION_PLAN_NAME') do
  its('type') { should eq 'Microsoft.Network/ddosProtectionPlans' }
end

Test to ensure that the DDoS protection plan resource is in a successful state:

describe azure_ddos_protection_resource(resource_group: 'RESOURCE_GROUP', name: 'DDOS_PROTECTION_PLAN_NAME') do
  its('provisioning_state') { should eq 'Succeeded' }
end

Test to ensure that the DDoS protection plan resource is from the same location:

describe azure_ddos_protection_resource(resource_group: 'RESOURCE_GROUP', name: 'DDOS_PROTECTION_PLAN_NAME') do
  its('location') { should eq `RESOURCE_LOCATION` }
end

Matchers

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

exists

# If a DDoS protection plan resource is found, it will exist.

describe azure_ddos_protection_resource(resource_group: 'RESOURCE_GROUP', name: 'DDOS_PROTECTION_PLAN_NAME') do
  it { should exist }
end

not_exists

# DDoS protection plan resources that aren't found, will not exist.

describe azure_ddos_protection_resource(resource_group: 'RESOURCE_GROUP', name: 'DDOS_PROTECTION_PLAN_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!

×