azure_bastion_hosts_resource Resource
Use the azure_bastion_hosts_resource
InSpec audit resource to test the properties related to a Bastion hosts resource.
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.
Install
This resource is available in the Chef InSpec Azure resource pack.
For information on configuring your Azure environment for Chef InSpec and creating an InSpec profile that uses the InSpec Azure resource pack, see the Chef InSpec documentation for the Azure cloud platform.
Syntax
resource_group
and bastion hosts resource name
, or the resource_id
are required parameters.
describe azure_bastion_hosts_resource(resource_group: 'RESOURCE_GROUP', name: 'NAME') do
it { should exist }
end
Parameters
resource_group
- Azure resource group where the targeted resource resides.
name
- Name of the virtual network to test.
Both the parameter sets should be provided for a valid query: resource_group
and name
.
Properties
name
- Name of the Azure resource to test.
tags
- A list of
tag:value
pairs defined on the resources. type
- type of Bastion hostname.
provisioning_state
- State of Bastion host name creation.
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 to ensure that the Bastion hosts resource is from the same type
describe azure_bastion_hosts_resource(resource_group: 'RESOURCE_GROUP', name: 'NAME') do
its('type') { should eq 'Microsoft.Network/bastionHosts' }
end
Test to ensure that the Bastion hosts resource is in a successful state
describe azure_bastion_hosts_resource(resource_group: 'RESOURCE_GROUP', name: 'NAME') do
its('provisioning_state') { should include('Succeeded') }
end
Test to ensure that the Bastion hosts resource is from the same location
describe azure_bastion_hosts_resource(resource_group: 'RESOURCE_GROUP', name: 'NAME') do
its('location') { should include df_location }
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 Bastion hosts resource is found, it will exist.
describe azure_bastion_hosts_resource(resource_group: 'RESOURCE_GROUP', name: 'NAME') do
it { should exist }
end
not_exists
# Bastion hosts resources that are not found, will not exist.
describe azure_bastion_hosts_resource(resource_group: 'RESOURCE_GROUP', name: 'DOES_NOT_EXIST') 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.