azure_redis_cache Resource
Use the azure_redis_cache
InSpec audit resource to test the properties related to an Azure Redis cache.
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 name
are required parameters.
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
it { should exist }
its('name') { should cmp 'REDIS_CACHE_NAME' }
its('type') { should cmp 'Microsoft.Cache/Redis' }
its('sku.name') { should cmp 'Standard' }
its('sku.family') { should cmp 'C' }
its('location') { should cmp 'southcentralus' }
end
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
it { should exist }
end
Parameters
resource_group
- Azure resource group that the targeted resource resides in.
MyResourceGroup
. name
- Name of the Azure Redis cache to test.
The parameter set should be provided for a valid query:
resource_group
andname
Properties
id
- Resource ID.
name
- Redis Cache Name.
location
- Redis Cache Location.
type
- Resource type.
tags
- Resource tags.
properties.sku.name
- The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium).
properties.sku.family
- The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium).
properties.sku.capacity
- The size of the Redis cache to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4).
properties.provisioningState
- The resource’s provisioning state.
properties.redisVersion
- Redis version.
properties.enableNonSslPort
- Specifies whether the non-SSL Redis server port (6379) is enabled.
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 (.
).
Examples
Test that the Redis instance’s provisioning status equals ‘Succeeded’.
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
its('properties.provisioningState') { should eq 'Succeeded' }
end
Test that the Redis instance Skuname equals ‘Standard’.
Skuname is the Redis cache to deploy. Valid values are Basic
, Standard
, Premium
.
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
its('properties.sku.name') { should eq 'Standard' }
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 redis cache is found it will exist
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
it { should exist }
end
# Redis Caches that aren't found will not exist
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
it { should_not exist }
end
be_enabled_non_ssl_port
Ensure that the Redis Cache supports non-SSL ports.
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
it { should be_enabled_non_ssl_port }
end
Azure Permissions
Your Service Principal must be set up with at least a contributor
role on the subscription you wish to test.