azure_monitor_log_profile Resource
Use the azure_monitor_log_profile
InSpec audit resource to test 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.
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
name
or the resource_id
must be given as a parameter.
describe azure_monitor_log_profile(name: 'my_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.
logProfileName
. resource_id
- The unique resource ID.
/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}
.
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
, 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 (.
), eg. properties.<attribute>
.
Examples
Test If a Log Profile is Referenced with a Valid Name.
describe azure_monitor_log_profile(name: 'my_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: 'my_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: 'InSpec_rg', name: 'my_storage_account') }
end
Matchers
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our Universal Matchers page.
have_log_retention_enabled
Test whether the log retention is enabled.
describe azure_monitor_log_profile(name: 'my_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: 'my_log_profile') do
it { should exist }
end
# If we expect a resource to never exist
describe azure_monitor_log_profile(name: 'my_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.