Class: LambdaDeployment::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lambda_deployment/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#concurrencyObject (readonly)

Returns the value of attribute concurrency.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def concurrency
  @concurrency
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def file_path
  @file_path
end

#kms_key_arnObject (readonly)

Returns the value of attribute kms_key_arn.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def kms_key_arn
  @kms_key_arn
end

#projectObject (readonly)

Returns the value of attribute project.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def project
  @project
end

#regionObject (readonly)

Returns the value of attribute region.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def region
  @region
end

#s3_bucketObject (readonly)

Returns the value of attribute s3_bucket.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def s3_bucket
  @s3_bucket
end

#s3_keyObject (readonly)

Returns the value of attribute s3_key.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def s3_key
  @s3_key
end

#s3_sseObject (readonly)

Returns the value of attribute s3_sse.



5
6
7
# File 'lib/lambda_deployment/configuration.rb', line 5

def s3_sse
  @s3_sse
end

Instance Method Details

#alias_nameObject

lambda aliases must satisfy (?!^[0-9]+$)(+)



25
26
27
28
29
30
# File 'lib/lambda_deployment/configuration.rb', line 25

def alias_name
  tag = ENV['TAG'].to_s.gsub(/[^a-zA-Z0-9\-_]/, '')
  return nil if tag.empty?
  tag.prepend 'v' if tag =~ /^[0-9]+$/ # just a number like 123 so lets turn it into v123
  tag
end

#environmentObject



32
33
34
35
36
# File 'lib/lambda_deployment/configuration.rb', line 32

def environment
  @environment ||= Dir.glob('.env*').reduce({}) do |cache, filename|
    cache.merge Dotenv::Environment.new(filename, true)
  end.merge(@config_env)
end

#load_config(config_file) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lambda_deployment/configuration.rb', line 7

def load_config(config_file)
  config = YAML.load_file(config_file)
  @project = config.fetch('project')
  @region = config.fetch('region', ENV.fetch('AWS_REGION', nil))
  @file_path = File.expand_path(config.fetch('file_name'), File.dirname(config_file))
  raise "File not found: #{@file_path}" unless File.exist?(@file_path)

  @s3_bucket = config.fetch('s3_bucket', ENV.fetch('LAMBDA_S3_BUCKET', nil))
  @s3_key = s3_key_name(config.fetch('file_name'))
  @s3_sse = config.fetch('s3_sse', ENV.fetch('LAMBDA_S3_SSE', nil))

  @config_env = config.fetch('environment', {})
  @kms_key_arn = config.fetch('kms_key_arn', ENV.fetch('LAMBDA_KMS_KEY_ARN', nil))

  @concurrency = config.fetch('concurrency', nil)
end