Class: Jets::Dotenv::Var
Constant Summary
collapse
- SSM_VARIABLE_REGEXP =
/^SSM:(.*)/i
Instance Attribute Summary collapse
Instance Method Summary
collapse
#log
#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2
#output_value, #stack_exists?
included, #reset_cache!
Constructor Details
#initialize(raw_key, raw_value) ⇒ Var
Returns a new instance of Var.
8
9
10
|
# File 'lib/jets/dotenv/var.rb', line 8
def initialize(raw_key, raw_value)
@raw_key, @raw_value = raw_key, raw_value
end
|
Instance Attribute Details
#raw_key ⇒ Object
Returns the value of attribute raw_key.
7
8
9
|
# File 'lib/jets/dotenv/var.rb', line 7
def raw_key
@raw_key
end
|
#raw_value ⇒ Object
Returns the value of attribute raw_value.
7
8
9
|
# File 'lib/jets/dotenv/var.rb', line 7
def raw_value
@raw_value
end
|
Instance Method Details
#name ⇒ Object
12
13
14
|
# File 'lib/jets/dotenv/var.rb', line 12
def name
@raw_key
end
|
#ssm? ⇒ Boolean
56
57
58
|
# File 'lib/jets/dotenv/var.rb', line 56
def ssm?
@raw_value&.start_with?("SSM")
end
|
#ssm_missing? ⇒ Boolean
51
52
53
54
|
# File 'lib/jets/dotenv/var.rb', line 51
def ssm_missing?
value !!@ssm_missing
end
|
#ssm_name ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/jets/dotenv/var.rb', line 22
def ssm_name
if @raw_value == "SSM"
Convention.new.ssm_name(@raw_key)
else
value = @raw_value.sub(/SSM:/i, "")
if value.start_with?("/")
value
else
Convention.new.ssm_name(value)
end
end
end
|
#ssm_value ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/jets/dotenv/var.rb', line 37
def ssm_value
return "fake-ssm-value" if ENV["JETS_NO_INTERNET"]
name = ssm_name
resp = ssm.get_parameter(name: name, with_decryption: true)
resp.parameter.value
rescue Aws::SSM::Errors::ParameterNotFound
@ssm_missing = true
nil
rescue Aws::SSM::Errors::ValidationException
puts "ERROR: Invalid SSM parameter name: #{name.inspect}".color(:red)
raise
end
|
#value ⇒ Object
16
17
18
|
# File 'lib/jets/dotenv/var.rb', line 16
def value
ssm? ? ssm_value : @raw_value
end
|