Class: TerraformWrapper::Shared::Auths::Azure

Inherits:
Common
  • Object
show all
Includes:
Logging
Defined in:
lib/terraform-wrapper/shared/auths/azure.rb

Constant Summary collapse

@@az =
"az"
@@type =
"azure"

Instance Method Summary collapse

Methods included from Logging

configure_logger_for, logger_for

Methods inherited from Common

#type

Constructor Details

#initialize(options:, variables:) ⇒ Azure

Returns a new instance of Azure.



38
39
40
# File 'lib/terraform-wrapper/shared/auths/azure.rb', line 38

def initialize(options:, variables:)
  construct(options: options, variables: variables)
end

Instance Method Details

#authObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/terraform-wrapper/shared/auths/azure.rb', line 44

def auth()
  details = subscription_details(subscription: @subscription)

  subscription = details["id"]
  tenant       = details["tenant"]
  username     = @keyvault.nil? ? nil : secret(vault: @keyvault, name: @secret_username)
  password     = @keyvault.nil? ? nil : secret(vault: @keyvault, name: @secret_password)

  ENV["ARM_SUBSCRIPTION_ID"] = subscription
  ENV["ARM_TENANT_ID"]       = tenant
  ENV["ARM_CLIENT_ID"]       = username unless username.nil?
  ENV["ARM_CLIENT_SECRET"]   = password unless password.nil?
  logger.success("Azure authenticator environment variables set!")
end

#clearObject



61
62
63
64
65
# File 'lib/terraform-wrapper/shared/auths/azure.rb', line 61

def clear()
  ENV.delete("ARM_SUBSCRIPTION_ID")
  ENV.delete("ARM_TENANT_ID")
  logger.info("Azure authenticator environment variables cleared!")
end