Class: Jets::Stack::Outputs
- Inherits:
-
Object
- Object
- Jets::Stack::Outputs
- Includes:
- AwsServices
- Defined in:
- lib/jets/stack/outputs.rb
Constant Summary collapse
- @@cache =
{}
Instance Method Summary collapse
-
#initialize(stack_subclass) ⇒ Outputs
constructor
A new instance of Outputs.
- #output_value(stack, key) ⇒ Object
-
#shared_stack_arn(logical_id) ⇒ Object
Shared child stack arn.
- #value(logical_id) ⇒ Object
Methods included from AwsServices
#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2
Methods included from AwsServices::StackStatus
Methods included from AwsServices::GlobalMemoist
Constructor Details
#initialize(stack_subclass) ⇒ Outputs
Returns a new instance of Outputs.
5 6 7 |
# File 'lib/jets/stack/outputs.rb', line 5 def initialize(stack_subclass) @stack_subclass = stack_subclass end |
Instance Method Details
#output_value(stack, key) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/jets/stack/outputs.rb', line 33 def output_value(stack, key) key = key.to_s.camelize output = stack.outputs.find do |o| o.output_key == key end output&.output_value end |
#shared_stack_arn(logical_id) ⇒ Object
Shared child stack arn
26 27 28 29 30 31 |
# File 'lib/jets/stack/outputs.rb', line 26 def shared_stack_arn(logical_id) parent_stack = Jets.project.namespace resp = cfn.describe_stacks(stack_name: parent_stack) parent = resp.stacks.first output_value(parent, logical_id) end |
#value(logical_id) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jets/stack/outputs.rb', line 10 def value(logical_id) logical_id = logical_id.to_s.camelize cache_key = "#{@stack_subclass}:#{logical_id}" return @@cache[cache_key] if @@cache[cache_key] child_stack_id = @stack_subclass.to_s.camelize stack_arn = shared_stack_arn(child_stack_id) resp = cfn.describe_stacks(stack_name: stack_arn) child = resp.stacks.first return unless child @@cache[cache_key] = output_value(child, logical_id) end |