Class: TerraspacePluginAzurerm::Interfaces::Backend::ResourceGroupCreator

Inherits:
Base
  • Object
show all
Defined in:
lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb

Overview

Named ResourceGroupCreator to avoid collision with Azure ResourceGroup model

Instance Method Summary collapse

Methods inherited from Base

#azure_info, #config, #initialize, #logger

Constructor Details

This class inherits a constructor from TerraspacePluginAzurerm::Interfaces::Backend::Base

Instance Method Details

#createObject


4
5
6
7
8
9
10
11
# File 'lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb', line 4

def create
  if exist?
    logger.debug "Resource Group #{@resource_group_name} already exists"
    create_or_update_resource_group if config.resource_group.update_existing
  else
    create_or_update_resource_group
  end
end

#create_or_update_resource_groupObject


17
18
19
20
21
22
23
24
# File 'lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb', line 17

def create_or_update_resource_group
  logger.info "Creating Resource Group #{@resource_group_name}..."
  resource_group.create_or_update(
    name: @resource_group_name,
    location: config.location || AzureInfo.location,
    tags: config.tags,
  )
end

#exist?Boolean

Returns:

  • (Boolean)

13
14
15
# File 'lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb', line 13

def exist?
  resource_group.check_existence(name: @resource_group_name)
end