0

Azure リソース グループにキー コンテナーが存在するかどうかをテストするための簡単な統合テストを作成しようとしています。

シェフ、ルビー、インスペックをインストールしました。プロファイルを初期化し、controls フォルダーの下に、次のようなテストがある example.rb ファイルがあります。

control 'azure_key_vault' do

  describe azure_key_vault(resource_group: '<my-resource-group-name', vault_name: "<my-key-vault-name") do
    it          { should exist }
    its('name') { should eq vault_name }
  end
end

~/.azure/credentialsリソース グループの set a service principal で Azure 資格情報を設定し、コマンドを実行しました。inspec exec ./azure_key_vault.rb -t azure://

しかし、次のエラーが発生しました:

Profile: tests from ./azure_key_vault.rb (tests from ..azure_key_vault.rb)
Version: (not specified)
Target:  azure://<subscription-id>

  ×  azure_key_vault: ./azure_key_vault.rb:4
     ×  Control Source Code Error ./azure_key_vault.rb:4 
     undefined method `azure_key_vault' for #<Inspec::Rule:0x00007fc536b14560>


Profile Summary: 0 successful controls, 1 control failure, 0 controls skipped
Test Summary: 0 successful, 1 failure, 0 skipped

そして、なぜこのエラーが発生するのかわかりません。そもそもエラーの原因azure_key_vaultazurerm_key_vault. 何か助けてください。

更新:ここでいくつかの更新。コマンドを実行すると:

inspec check .

私はこの結果を得ました:

[2021-03-22T19:06:29+00:00] WARN: DEPRECATION: `azurerm_resource_groups` uses the new resource `azure_resource_groups` under the hood. azurerm_resource_groups will be deprecated soon and it is advised to switch to the fully backward compatible new resource. Please see the documentation for the additional features available.
[2021-03-22T19:06:29+00:00] ERROR: The following must be set in the Environment: [:tenant_id, :client_id, :client_secret, :subscription_id].
Missing: [:tenant_id, :client_id, :client_secret, :subscription_id]
W, [2021-03-22T19:06:29.553721 #15226]  WARN -- : Control azurerm_resource_groups has no title
W, [2021-03-22T19:06:29.554013 #15226]  WARN -- : Control azurerm_resource_groups has no descriptions
Location :   .
Profile :    my-azureTests
Controls :   1
Timestamp :  2021-03-22T19:06:29+00:00
Valid :      true

 !  ./controls/resourcegroup.rb:1: Control azurerm_resource_groups has no title
 !  ./controls/resourcegroup.rb:1: Control azurerm_resource_groups has no descriptions

Summary:     0 errors, 2 warnings

が私のERROR注意を引きました。credentials内部にファイル (拡張子なし)を作成/.azureし、次のように資格情報を渡したと確信しています。

[<my-subscription-id>]
client_id="<my-client-id"
client_secret="<my-secret>"
tenant_id="<my-tenant-id>"

なしで< >

inspec が私の詳細を認識しない理由がよくわかりません

4

0 に答える 0