Class: Hiera::Backend::Aws::Cloudformation

Inherits:
Base
  • Object
show all
Defined in:
lib/hiera/backend/aws/cloudformation.rb

Overview

Implementation of Hiera keys for aws/cloudformation

Instance Attribute Summary

Attributes inherited from Base

#scope

Instance Method Summary collapse

Methods inherited from Base

#aws_account_number, #aws_region, #puppet_fact, #stringify_keys

Constructor Details

#initialize(scope = {}) ⇒ Cloudformation

Returns a new instance of Cloudformation.



8
9
10
11
# File 'lib/hiera/backend/aws/cloudformation.rb', line 8

def initialize(scope = {})
  super(scope)
  @client = AWS::CloudFormation::Client.new
end

Instance Method Details

#lookup(key, scope) ⇒ Object

Override default key lookup to implement custom format. Examples:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hiera/backend/aws/cloudformation.rb', line 14

def lookup(key, scope)
  r = super(key, scope)
  return r if r

  args = key.split
  return if args.shift != "cloudformation"
  parameters = Hash[args.map { |t| t.split("=") }]
  stack_name = parameters.fetch("stack")
  output_key = parameters.fetch("output")
  lookup_cfn_output_value(stack_name, output_key)
end