title | platform |
---|---|
About the azure_monitor_log_profile Resource |
azure |
Use the azure_monitor_log_profile
InSpec audit resource to test properties and configuration of an Azure log profile.
This resource interacts with api versions supported by the resource provider.
The api_version
can be defined as a resource parameter.
If not provided, the latest version will be used.
For more information, refer to azure_generic_resource
.
Unless defined, azure_cloud
global endpoint, and default values for the http client will be used.
For more information, refer to the resource pack README.
This resource is available in the InSpec Azure resource pack.
For an example inspec.yml
file and how to set up your Azure credentials, refer to resource pack README.
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
Name | Description |
---|---|
name | Name of the log profile to test. logProfileName |
resource_id | The unique resource ID. /subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName} |
Property | Description |
---|---|
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 the resouce_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>
.
describe azure_monitor_log_profile(name: 'my_log_profile') do
it { should exist }
end
describe azure_monitor_log_profile(name: 'i-dont-exist') do
it { should_not exist }
end
describe azure_monitor_log_profile(name: 'my_log_profile') do
its('retention_days') { should be 90 }
end
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
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our Universal Matchers page.
Test whether the log retention is enabled.
describe azure_monitor_log_profile(name: 'my_log_profile') do
it { should have_log_retention_enabled }
end
# 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
Your Service Principal must be setup with a contributor
role on the subscription you wish to test.