Skip to main content

azure_bastion_hosts_resource Resource

Use the azure_bastion_hosts_resource InSpec audit resource to test 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.

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

resource_group and bastion hosts resource name or the resource_id must be given as a parameter.

describe azure_bastion_hosts_resource(resource_group: 'MyResourceGroup', name: 'bastion_name') do
  it { should exist }
end

Parameters

resource_group
Azure resource group that the targeted resource resides in. MyResourceGroup.
name
Name of the virtual network to test. MyVNetwork.

Both of the parameter sets should be provided for a valid query:

  • resource_group and name

Properties

name
Name of the Azure resource to test. MyBastionHostName.
tags
A list of tag:value pairs defined on the resources.
type
type of BastionHostName.
provisioning_state
State of BastionHostName 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

Ensure that the bastion hosts resource has is from same type.

describe azure_bastion_hosts_resource(resource_group: 'MyResourceGroup', name: 'bastion_name') do
  its('type') { should eq 'Microsoft.Network/bastionHosts' }
end

Ensure that the bastion hosts resource is in successful state.

describe azure_bastion_hosts_resource(resource_group: 'MyResourceGroup', name: 'bastion_name') do
  its('provisioning_state') { should include('Succeeded') }
end

Ensure that the bastion hosts resource is from same location.

describe azure_bastion_hosts_resource(resource_group: 'MyResourceGroup', name: 'bastion_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: 'MyResourceGroup', name: 'MyBastionHostName') do
  it { should exist }
end

# bastion hosts resources that aren't found will not exist
describe azure_bastion_hosts_resource(resource_group: 'MyResourceGroup', name: 'DoesNotExist') 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.

Edit this page on GitHub

Thank you for your feedback!

×









Search Results