Method: Inspec::Resources::AzureResourceGroup#initialize

Defined in:
lib/resources/azure/azure_resource_group.rb

#initialize(opts) ⇒ AzureResourceGroup

Constructor to get the resource group itself and perform some analysis on the resources that in the resource group.

This analysis is defined by the the mapping hashtable which is used to define the ‘has_xxx?’ methods (see AzureResourceGroup#create_has_methods) and return the counts for each type



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/resources/azure/azure_resource_group.rb', line 25

def initialize(opts)
  opts.key?(:name) ? opts[:group_name] = opts[:name] : false
  # Ensure that the opts only have the name of the resource group set

  opts.select! { |k, _v| k == :group_name }
  super(opts)

  # set the mapping for the Azure Resources

  @mapping = {
    nic: 'Microsoft.Network/networkInterfaces',
    vm: 'Microsoft.Compute/virtualMachines',
    extension: 'Microsoft.Compute/virtualMachines/extensions',
    nsg: 'Microsoft.Network/networkSecurityGroups',
    vnet: 'Microsoft.Network/virtualNetworks',
    managed_disk: 'Microsoft.Compute/disks',
    managed_disk_image: 'Microsoft.Compute/images',
    sa: 'Microsoft.Storage/storageAccounts',
    public_ip: 'Microsoft.Network/publicIPAddresses',
  }

  # Get information about the resource group itself

  resource_group

  # Get information about the resources in the resource group

  resources

  # Call method to create the has_xxxx? methods

  create_has_methods

  # Call method to allow access to the tag values

  create_tag_methods
end