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.
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
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.
- A list of
tag:value
pairs defined on the resources. type
- type of Bastion hostname.
provisioning_state
- State of Bastion host name creation.
Also, see the Azure documentation for other available properties. You can access any attribute in the response 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
For a full list of available matchers, see 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.