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.
You can specify the api_version
as a resource parameter to use a specific version of the Azure REST API.
If you don’t specify an API version, this resource uses the latest version available.
For more information about API versioning, see the azure_generic_resource
.
By default, this resource uses the azure_cloud
global endpoint and default HTTP client settings.
You can override these settings if you need to connect to a different Azure environment (such as Azure Government or Azure China).
For more information about configuration options, see the resource pack README.
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 where the targeted resource resides.
name
- Name of the Azure Redis cache to test.
The parameter set should be provided for a valid query are resource_group
and name
.
Properties
id
- Resource ID.
name
- Redis cache name.
location
- Redis cache location.
type
- Resource type.
- Resource tags.
properties.sku.name
- The type of Redis cache to deploy. Valid values are
Basic
,Standard
, andPremium
. properties.sku.family
- The SKU family to use. Valid values are
C
andP
(C = Basic/Standard, P = Premium). properties.sku.capacity
- The size of the Redis cache to deploy. Valid values are
C
(Basic/Standard; family: 0, 1, 2, 3, 4, 5, 6) andP
(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
, and properties
, refer to azure_generic_resource
.
Also, see the Azure documentation for other available properties.
You can access any attribute in the response 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
, and Premium
.
describe azure_redis_cache(resource_group: 'RESOURCE_GROUP', name: 'REDIS_CACHE_NAME') do
its('properties.sku.name') { should eq 'Standard' }
end
Matchers
For a full list of available matchers, see 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
not_exists
# 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.