Sha256: c0a52b247870653c2da22801d5cafc300e0dd859ee3d984652d570c929431e57

Contents?: true

Size: 936 Bytes

Versions: 10

Compression:

Stored size: 936 Bytes

Contents

class TerraspacePluginAzurerm::Interfaces::Backend
  # Named ResourceGroupCreator to avoid collision with Azure ResourceGroup model
  class ResourceGroupCreator < Base
    include TerraspacePluginAzurerm::Clients::Resources

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

    def exist?
      resource_groups.check_existence(@resource_group_name)
    end

    def create_resource_group
      logger.info "Creating Resource Group #{@resource_group_name}..."
      resource_group = ResourceGroup.new
      resource_group.name = @resource_group_name
      resource_group.location = config.location || AzureInfo.location
      resource_groups.create_or_update(@resource_group_name, resource_group)
    end

  private
    def resource_groups
      ResourceGroups.new(mgmt)
    end
    memoize :resource_groups
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
terraspace_plugin_azurerm-0.3.3 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.3.2 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.3.1 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.3.0 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.2.3 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.2.2 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.2.1 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.2.0 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.1.1 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb
terraspace_plugin_azurerm-0.1.0 lib/terraspace_plugin_azurerm/interfaces/backend/resource_group_creator.rb