class TerraformWrapper::Shared::Backends::Azure
Attributes
account[R]
container[R]
group[R]
key[R]
Public Class Methods
new(options:, variables:)
click to toggle source
# File lib/terraform-wrapper/shared/backends/azure.rb, line 34 def initialize(options:, variables:) construct(options: options, variables: variables) end
Public Instance Methods
hash()
click to toggle source
# File lib/terraform-wrapper/shared/backends/azure.rb, line 40 def hash() return { "container_name" => @container, "key" => @key, "resource_group_name" => @group, "storage_account_name" => @account } end
Private Instance Methods
specific()
click to toggle source
# File lib/terraform-wrapper/shared/backends/azure.rb, line 55 def specific() logger.fatal("Azure backend mandatory option 'group' has not been set!") unless @options.key?("group") group = @options["group"] logger.fatal("Azure backend group must be a string!") unless group.kind_of?(String) logger.fatal("Azure backend group must not be blank!") if group.strip.empty? account = @options.key?("account") ? @options["account"] : group + "tf" logger.fatal("Azure backend storage account must be a string!") unless account.kind_of?(String) logger.fatal("Azure backend storage account must not be blank!") if account.strip.empty? container = @options.key?("container") ? @options["container"] : "default" logger.fatal("Azure backend storage account container must be a string!") unless container.kind_of?(String) logger.fatal("Azure backend storage account container must not be blank!") if container.strip.empty? key = @options.key?("key") ? @options["key"] : File.join("%{service}", "%{config}", "%{component}" + @@ext) logger.fatal("Azure backend storage account key must be a string!") unless key.kind_of?(String) logger.fatal("Azure backend storage account key must not be blank!") if key.strip.empty? @variables.core.keys.map{ |sym| sym.to_s }.each do |core| logger.fatal("Azure backend container or key must include %{#{core}}.") unless (container.include?("%{#{core}}") or key.include?("%{#{core}}")) end begin group = group % @variables.identifiers account = account % @variables.identifiers container = container % @variables.identifiers key = key % @variables.identifiers rescue logger.fatal("Azure backend options contain identifiers that are not included in the configuration file!") end if key.length > 1024 then logger.fatal("Key: #{key} is too long for backend of type: #{@@type}") else logger.warn("Key for backend of type: #{@@type} exceeds 256 characters. This will not work with the Azure Storage Emulator. If key is not being overriden, consider using less identifiers.") if key.length > 256 end @group = group @account = account @container = container @key = key end