azure_monitor_log_profile Resource
Use the azure_monitor_log_profile
InSpec audit resource to test the properties and configuration of an Azure Log profile.
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
name
or the resource_id
are required parameters.
describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
it { should exist }
end
describe azure_monitor_log_profile(resource_id: '/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}') do
it { should exist }
end
Parameters
name
- Name of the log profile to test.
resource_id
- The unique resource ID.
Properties
retention_policy
- The retention policy for the events in the log with these properties.
retention_days
- The number of days for the log retention in days. A value of
0
means that the events will be retained indefinitely. storage_account
- A hash containing the
name
and theresouce_group
of the storage account in which the activity logs are kept.
For properties applicable to all resources, such as type
, name
, id
, and properties
, refer to azure_generic_resource
.
Also, refer to Azure documentation for other properties available.
Any attribute in the response may be accessed with the key names separated by dots (.
). For example, properties.<attribute>
.
Examples
Test if a Log profile is referenced with a valid name
describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
it { should exist }
end
Test if a Log profile is referenced with an invalid name
describe azure_monitor_log_profile(name: 'i-dont-exist') do
it { should_not exist }
end
Test the retention days of a Log profile
describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
its('retention_days') { should be 90 }
end
Test the storage account of a Log profile
describe azure_monitor_log_profile(resource_id: '/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}') do
its('storage_account') { should eql(resource_group: 'RESOURCE_GROUP', name: 'STORAGE_ACCOUNT') }
end
Matchers
For a full list of available matchers, see our Universal Matchers page.This resource has the following special matchers.
have_log_retention_enabled
Test whether the log retention is enabled.
describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
it { should have_log_retention_enabled }
end
exists
# If we expect a resource to always exist.
describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
it { should exist }
end
not_exists
# If we expect a resource to never exist.
describe azure_monitor_log_profile(name: 'LOG_PROFILE') 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.