Class: LambdaDeployment::Configuration
- Inherits:
-
Object
- Object
- LambdaDeployment::Configuration
- Defined in:
- lib/lambda_deployment/configuration.rb
Instance Attribute Summary collapse
-
#concurrency ⇒ Object
readonly
Returns the value of attribute concurrency.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#kms_key_arn ⇒ Object
readonly
Returns the value of attribute kms_key_arn.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#s3_bucket ⇒ Object
readonly
Returns the value of attribute s3_bucket.
-
#s3_key ⇒ Object
readonly
Returns the value of attribute s3_key.
-
#s3_sse ⇒ Object
readonly
Returns the value of attribute s3_sse.
Instance Method Summary collapse
-
#alias_name ⇒ Object
lambda aliases must satisfy (?!^[0-9]+$)(+).
- #environment ⇒ Object
- #load_config(config_file) ⇒ Object
Instance Attribute Details
#concurrency ⇒ Object (readonly)
Returns the value of attribute concurrency.
5 6 7 |
# File 'lib/lambda_deployment/configuration.rb', line 5 def concurrency @concurrency end |
#file_path ⇒ Object (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_arn ⇒ Object (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 |
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'lib/lambda_deployment/configuration.rb', line 5 def project @project end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
5 6 7 |
# File 'lib/lambda_deployment/configuration.rb', line 5 def region @region end |
#s3_bucket ⇒ Object (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_key ⇒ Object (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_sse ⇒ Object (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_name ⇒ Object
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 |
#environment ⇒ Object
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.(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 |