Class: Jets::CLI::Lambda::Lookup
- Inherits:
-
Object
- Object
- Jets::CLI::Lambda::Lookup
show all
- Includes:
- AwsServices
- Defined in:
- lib/jets/cli/lambda/lookup.rb
Defined Under Namespace
Classes: Error
Constant Summary
collapse
- MAX_FUNCTION_NAME_SIZE =
64
Class Method Summary
collapse
Instance Method Summary
collapse
#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(name) ⇒ Lookup
18
19
20
|
# File 'lib/jets/cli/lambda/lookup.rb', line 18
def initialize(name)
@name = name
end
|
Class Method Details
.function(name) ⇒ Object
12
13
14
|
# File 'lib/jets/cli/lambda/lookup.rb', line 12
def function(name)
new(name).lookup
end
|
Instance Method Details
#function_name ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/jets/cli/lambda/lookup.rb', line 23
def function_name
name = if @name.starts_with?(Jets.project.namespace)
@name elsif !ENV["JETS_RESET"]
[Jets.project.namespace, @name].join("-")
else
lookup
end
(name.size > MAX_FUNCTION_NAME_SIZE) ? lookup : name
end
|
#lookup ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/jets/cli/lambda/lookup.rb', line 34
def lookup
if @name == "controller"
class_name, meth = "Controller", ""
else
parts = @name.split("-")
meth = parts.pop.tr("-", "_").camelize
class_name = parts.join("_").camelize
end
parent_name = Jets::Names.parent_stack_name
parent = cfn.describe_stacks(stack_name: parent_name).stacks.first
unless parent
raise Error::ParentStack, "Unable to find parent stack #{parent_name}"
end
output = parent.outputs.find { |o| o.output_key == class_name }
unless output
raise Error::Output, "Unable to find output #{class_name} in parent stack #{parent_name}"
end
child_name = output.output_value
child = cfn.describe_stacks(stack_name: child_name).stacks.first
unless child
raise Error::ChildStack, "Unable to find child stack #{parent_name}"
end
output = child.outputs.find { |o| o.output_key == "#{meth}LambdaFunction" }
output.output_value
end
|