hiera_dynamodb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fcf215e3599a0ce4ea8e59fe8601ed5b8c3d2521f35f00663de2efa19200cc86
4
+ data.tar.gz: 39dd8826ea4553f6f704bc47cc37ee5f7454a018524c6fb2782ca0e34959a8f9
5
+ SHA512:
6
+ metadata.gz: f87bf6caaefa06b14dd4ade45e80e7fd0a0ae13a658b7011e031d5f479b58d2f8c132c7028f581c38d669199ae31ce2059a55e12242ef161e8f0b28e1c818d0e
7
+ data.tar.gz: c7b8945b7265b8c025fe538f6d1a5a0256cc0c54c3d8fbdfd96ca774233a760fee384e19da32bef9895a31a5e5d729f295f7dbfcac92cd6a8a7ff1b1e0e15ab9
@@ -0,0 +1,59 @@
1
+ class Hiera
2
+ module Backend
3
+ # Hiera DynamoDB backend
4
+ class Dynamodb_backend
5
+ def initialize
6
+ begin
7
+ require 'aws-sdk-dynamodb'
8
+ require 'rubygems'
9
+ end
10
+ end
11
+
12
+ def lookup(key, scope, order_override, resolution_type)
13
+ if Config.include?(:dynamodb) && !Config[:dynamodb].nil?
14
+ aws_config = {}
15
+ if Config[:dynamodb].include?(:access_key_id) && Config[:dynamodb].include?(:secret_access_key)
16
+ Hiera.debug("Found AWS Access Key #{Config[:dynamodb][:access_key_id]} from configuration")
17
+ aws_config[:access_key_id] = Config[:dynamodb][:access_key_id]
18
+ aws_config[:secret_access_key] = Config[:dynamodb][:secret_access_key]
19
+ end
20
+ if Config[:dynamodb].include?(:region)
21
+ Hiera.debug("Found AWS region #{Config[:dynamodb][:region]} from configuration")
22
+ aws_config[:region] = Config[:dynamodb][:region]
23
+ end
24
+ if aws_config.length != 0
25
+ Hiera.debug('loading DynamoDB backend')
26
+ ddb = Aws::DynamoDB::Client.new(aws_config)
27
+ else
28
+ Hiera.debug('No AWS configuration found, will fall back to env variables or IAM role')
29
+ ddb = Aws::DynamoDB::Client.new
30
+ end
31
+ else
32
+ Hiera.debug('No configuration found, will fall back to env variables or IAM role')
33
+ ddb = Aws::DynamoDB::Client.new
34
+ end
35
+ if Config[:dynamodb].include?(:table)
36
+ table = Config[:dynamodb][:table]
37
+ else
38
+ table = 'puppet'
39
+ end
40
+ Hiera.debug("Hiera dynamodb Client connected. Checking that table: #{table} requested in config exists")
41
+ exists = ddb.list_tables({})
42
+ Hiera.debug(exists)
43
+ Hiera.debug("Looking for #{key}")
44
+ resp = ddb.get_item({
45
+ key: {
46
+ "hiera_key" => key,
47
+ },
48
+ table_name: table,
49
+ })
50
+ Hiera.debug(resp.to_h)
51
+ items = resp.to_h[:item]
52
+ Hiera.debug(items)
53
+ answer = items["hiera_value"]
54
+ Hiera.debug("Value Returned: #{answer}")
55
+ return answer
56
+ end
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hiera_dynamodb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andy Brown
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hiera
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-dynamodb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email: andy@techdad.tech
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - lib/hiera/backend/dynamodb_backend.rb
62
+ homepage: http://github.com/andytechdad/hiera-dynamodb
63
+ licenses: []
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib/hiera/backend
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Use AWS DynamoDB as a hiera backend
84
+ test_files: []