Project: Chef InSpec (Provisioning / Security & Compliance)
File: azurerm_key_vault_secret.md

+++ title = "azurermkeyvault_secret resource" draft = false gh_repo = "inspec" platform = "azure" [menu] [menu.inspec] title = "azurermkeyvault_secret" identifier = "inspec/resources/azure/azurermkeyvaultsecret.md azurermkeyvaultsecret resource" parent = "inspec/resources/azure" +++ {{< inspec/azurermdeprecated resource="azurekeyvaultsecret" >}} Use the `azurermkeyvault_secret` InSpec audit resource to test properties and configuration of an Azure Secret within a Vault. This resource interacts with version `2016-10-01` of the Azure Management API. For more information see the . At the moment, there doesn't appear to be a way to select the version of the Azure API docs. If you notice a newer version being referenced in the official documentation please open an issue or submit a pull request using the updated version. This resource is available in the `inspec-azure` [resource pack](/inspec/glossary/#resource-pack). To use it, add the following to your `inspec.yml` in your top-level profile: depends: name: inspec-azure git: https://github.com/inspec/inspec-azure.git You'll also need to setup your Azure credentials; see the resource pack . This resource first became available in 1.3.0 of the inspec-azure resource pack. The `vaultname` and `secretname` must be given as a parameter. You may also specify a `secret_version` - if no version is specified, the most recent version of the secret will be used. describe azurermkeyvault_secret('vault-101', 'secret-101') do it { should exist } its('value') { shouldnot benil } end If a Key Vault Secret is referenced with a valid `Vault Name`, `Secret Name` and `Secret Version` describe azurermkeyvault_secret('vault-101', 'secret-101', '7df9bf2c3b4347bab213ebe233f0e350') do its('value') { shouldnot benil } end If a Key Vault Secret is referenced with an invalid `Vault Name` or `Secret Name` describe azurermkeyvault_secret('vault-101', 'incorrect-secret') do it { should_not exist } end `vault_name` - The name of the Key Vault. `secret_name` - The name of the Key. `secret_version` (Optional) - The version of a Key, e.g. `7df9bf2c3b4347bab213ebe233f0e350`. `id` `value` `attributes` `kid` `content_type` `managed` `tags` The secret id. The secret value. The secret management attributes. If this is a secret backing a KV certificate, then this field specifies the corresponding key backing the KV certificate. The content type of the secret. True if the secret's lifetime is managed by key vault. If this is a secret backing a certificate, then managed will be true. Resource tags applied to the Secret. There are additional attributes that may be accessed that we have not documented. Please take a look at the . Any attribute in the response may be accessed with the key names separated by dots (`.`). The API may not always return keys that do not have any associated data. There may be cases where the deeply nested property may not have the desired attribute along your call chain. If you find yourself writing tests against properties that may be nil, fork this resource pack and add an accessor to the resource. Within that accessor you'll be able to guard against nil keys. Pull requests are always welcome. {{< readfile file="content/inspec/reusable/md/inspecmatcherslink.md" >}} This resource has the following special matchers. describe azurermkeyvault_secret('vault-101', 'secret') do it { should exist } end Your must be setup with a `contributor` role on the subscription you wish to test. Your Azure Key Vault should also have this Service Principal listed in it's Access Policy with both `secret/get` and `secret/list` permissions.