hiera-aws 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.rubocop.yml +2 -0
- data/.travis.yml +3 -1
- data/CHANGELOG.md +9 -0
- data/README.md +12 -8
- data/Rakefile +10 -4
- data/hiera-aws.gemspec +1 -1
- data/lib/hiera/backend/aws/elasticache.rb +14 -2
- data/lib/hiera/backend/aws/rds.rb +2 -1
- data/lib/hiera/backend/aws/version.rb +1 -1
- data/spec/aws_elasticache_spec.rb +206 -177
- data/spec/aws_rds_spec.rb +21 -6
- metadata +54 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df09cbafee105c292fccfa418ce737723bcbdfe2
|
4
|
+
data.tar.gz: c605c9aff9a2743e3f6a81bad3828ba4f98b370a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f44cb460fc933f9caf7ae5f8e0e5f9370eeba2dd40b1d04e77dad2468707180df49712ee6a66e0046fc79b7d7fbfe7eeaeb4cbcbc65f7802604492fb17adf55
|
7
|
+
data.tar.gz: d2aab23ef2d552d48b0f9b58dcdbf5e2ce88dbb86df42d9ddb78c0fcd8c6cd28585c2a16082a94f1ec97ae35c23b8aa2beccfc9c64d8f62760d9a38827f3727a
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## v0.5.0 (May 15 2014)
|
2
|
+
|
3
|
+
* Change `redis_cluster_nodes_for_cfn_stack`, `memcached_cluster_nodes_for_cfn_stack`,
|
4
|
+
and `redis_cluster_replica_groups_for_cfn_stack` to only return resources that
|
5
|
+
are in state "available".
|
6
|
+
* Change `redis_cluster_replica_groups_for_cfn_stack` response to include
|
7
|
+
`latest_cache_cluster_create_time`, which is the creation time unix timestamp
|
8
|
+
of the most current cache cluster in each replication group.
|
9
|
+
|
1
10
|
## v0.4.1 (May 12 2014)
|
2
11
|
|
3
12
|
* Disable real HTTP connections in RSpec tests by using
|
data/README.md
CHANGED
@@ -67,7 +67,8 @@ The backend currently supports the following keys that you can pass to the
|
|
67
67
|
### redis_cluster_nodes_for_cfn_stack
|
68
68
|
|
69
69
|
Returns an array of all Redis cluster nodes for the CloudFormation stack of an
|
70
|
-
EC2 instance.
|
70
|
+
EC2 instance. Only cluster nodes that are in state "available" are returned. The
|
71
|
+
instance is identified by the Puppet fact `$ec2_instance_id`.
|
71
72
|
|
72
73
|
Usage:
|
73
74
|
|
@@ -86,8 +87,9 @@ For each Redis cluster node in the array the following hash is returned:
|
|
86
87
|
### redis_cluster_replica_groups_for_cfn_stack
|
87
88
|
|
88
89
|
Returns an array of the Redis Replication Groups of all Redis cluster nodes for
|
89
|
-
the CloudFormation stack of an EC2 Instance.
|
90
|
-
Puppet fact
|
90
|
+
the CloudFormation stack of an EC2 Instance. Only Replication Groups that are in
|
91
|
+
state "available" are returned. The instance is identified by the Puppet fact
|
92
|
+
`$ec2_instance_id`.
|
91
93
|
|
92
94
|
Usage:
|
93
95
|
|
@@ -100,15 +102,17 @@ For each replica group in the array the following hash is returned:
|
|
100
102
|
```json
|
101
103
|
{
|
102
104
|
"replication_group_id" => "some-group-id",
|
103
|
-
"primary_endpoint" => { "address" => "some.replication.group.primary.endpoint", "port" => 1234 }
|
105
|
+
"primary_endpoint" => { "address" => "some.replication.group.primary.endpoint", "port" => 1234 },
|
106
|
+
"latest_cache_cluster_create_time" => 1400155680
|
104
107
|
}
|
105
108
|
```
|
106
109
|
|
107
110
|
### memcached_cluster_nodes_for_cfn_stack
|
108
111
|
|
109
112
|
Returns an array of all Memcached cluster nodes for the CloudFormation stack of
|
110
|
-
an EC2 instance.
|
111
|
-
|
113
|
+
an EC2 instance. Only cluster nodes that are in state "available" are returned.
|
114
|
+
The instance is identified by the Puppet fact `$ec2_instance_id`. The returned
|
115
|
+
array has the format `["host1", "host2"]`.
|
112
116
|
|
113
117
|
Usage:
|
114
118
|
|
@@ -118,8 +122,8 @@ cluster_nodes = hiera("memcached_cluster_nodes_for_cfn_stack")
|
|
118
122
|
|
119
123
|
### rds_instances tag=value...
|
120
124
|
|
121
|
-
Returns an array of all RDS database instances that
|
122
|
-
assigned.
|
125
|
+
Returns an array of all RDS database instances that are in state "available" and
|
126
|
+
have one or more tags assigned.
|
123
127
|
|
124
128
|
For each instance in the array the following hash is returned:
|
125
129
|
|
data/Rakefile
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
-
require "rubocop/rake_task"
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
# RuboCop only works with newer Ruby versions
|
5
|
+
if RUBY_VERSION >= "1.9.2"
|
6
|
+
require "rubocop/rake_task"
|
7
|
+
|
8
|
+
desc "Run RuboCop style and lint checks"
|
9
|
+
Rubocop::RakeTask.new(:rubocop)
|
10
|
+
|
11
|
+
task :test => :rubocop
|
12
|
+
end
|
7
13
|
|
8
14
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
9
15
|
t.rspec_opts = "--color --format documentation"
|
10
16
|
end
|
11
17
|
|
12
|
-
task :test =>
|
18
|
+
task :test => :spec
|
13
19
|
task :default => :test
|
data/hiera-aws.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "rubocop", "~> 0.21.0"
|
26
|
+
spec.add_development_dependency "rubocop", "~> 0.21.0" if RUBY_VERSION >= "1.9.2"
|
27
27
|
spec.add_development_dependency "webmock"
|
28
28
|
end
|
@@ -46,6 +46,8 @@ class Hiera
|
|
46
46
|
end.map do |r|
|
47
47
|
cluster_id = r.physical_resource_id
|
48
48
|
cache_cluster_info(cluster_id)
|
49
|
+
end.select do |cluster|
|
50
|
+
cluster.fetch(:cache_cluster_status) == "available"
|
49
51
|
end.select do |cluster|
|
50
52
|
# Filter by engine type if provided
|
51
53
|
if cluster_engine
|
@@ -71,6 +73,7 @@ class Hiera
|
|
71
73
|
raise MissingFactError, "ec2_instance_id not found" unless ec2_instance_id
|
72
74
|
|
73
75
|
replica_groups = {}
|
76
|
+
cluster_create_times = {}
|
74
77
|
stack_name = cfn_stack_name(ec2_instance_id)
|
75
78
|
|
76
79
|
clusters = cache_clusters_in_cfn_stack(stack_name, cluster_engine)
|
@@ -78,10 +81,18 @@ class Hiera
|
|
78
81
|
replication_group_id = cluster[:replication_group_id]
|
79
82
|
next unless replication_group_id
|
80
83
|
|
84
|
+
cache_cluster_create_time = cluster.fetch(:cache_cluster_create_time)
|
85
|
+
if cluster_create_times[replication_group_id].nil? || cluster_create_times[replication_group_id] < cache_cluster_create_time
|
86
|
+
cluster_create_times[replication_group_id] = cache_cluster_create_time
|
87
|
+
end
|
88
|
+
|
81
89
|
client = AWS::ElastiCache::Client.new
|
90
|
+
|
82
91
|
replication_group = client.describe_replication_groups(:replication_group_id => replication_group_id)[:replication_groups].first
|
92
|
+
next unless replication_group.fetch(:status) == "available"
|
83
93
|
|
84
|
-
|
94
|
+
node_group = replication_group.fetch(:node_groups).first
|
95
|
+
primary_endpoint = node_group.fetch(:primary_endpoint)
|
85
96
|
|
86
97
|
replica_groups[replication_group_id] = {
|
87
98
|
:primary_endpoint => primary_endpoint
|
@@ -91,7 +102,8 @@ class Hiera
|
|
91
102
|
replica_groups.map do |k, v|
|
92
103
|
{
|
93
104
|
"replication_group_id" => k,
|
94
|
-
"primary_endpoint" => stringify_keys(v[:primary_endpoint])
|
105
|
+
"primary_endpoint" => stringify_keys(v[:primary_endpoint]),
|
106
|
+
"latest_cache_cluster_create_time" => cluster_create_times[k].strftime("%s"),
|
95
107
|
}
|
96
108
|
end
|
97
109
|
end
|
@@ -33,7 +33,8 @@ class Hiera
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def db_instances
|
36
|
-
@
|
36
|
+
@client.describe_db_instances[:db_instances].
|
37
|
+
select { |i| i[:db_instance_status] == "available" }
|
37
38
|
end
|
38
39
|
|
39
40
|
def db_instances_with_tags(tags)
|
@@ -1,9 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "hiera/backend/aws/elasticache"
|
3
|
+
require "date"
|
3
4
|
|
4
5
|
class Hiera
|
5
6
|
module Backend # rubocop:disable Documentation
|
6
7
|
describe Aws::ElastiCache do
|
8
|
+
|
9
|
+
let(:time_earlier) { Time.new }
|
10
|
+
let(:time_later) { time_earlier + 1 }
|
11
|
+
|
7
12
|
let(:ec2_client) do
|
8
13
|
double(
|
9
14
|
:instances => {
|
@@ -13,46 +18,175 @@ class Hiera
|
|
13
18
|
}
|
14
19
|
)
|
15
20
|
end
|
21
|
+
|
16
22
|
let(:cfn_client) do
|
17
23
|
double(
|
18
24
|
:stacks => {
|
19
25
|
"some-stack-name" => double(
|
20
26
|
:resources => [
|
27
|
+
# these are listed in reverse/random order to proove that
|
28
|
+
# tests don't rely on ordering.
|
29
|
+
double(
|
30
|
+
:resource_type => "AWS::ElastiCache::CacheCluster",
|
31
|
+
:physical_resource_id => "another-redis-cluster-id"
|
32
|
+
),
|
21
33
|
double(
|
22
34
|
:resource_type => "AWS::ElastiCache::CacheCluster",
|
23
|
-
:physical_resource_id => "some-cluster-id"
|
24
|
-
)
|
35
|
+
:physical_resource_id => "some-redis-cluster-id"
|
36
|
+
),
|
37
|
+
double(
|
38
|
+
:resource_type => "AWS::ElastiCache::CacheCluster",
|
39
|
+
:physical_resource_id => "another-memcache-cluster-id"
|
40
|
+
),
|
41
|
+
double(
|
42
|
+
:resource_type => "AWS::ElastiCache::CacheCluster",
|
43
|
+
:physical_resource_id => "some-memcache-cluster-id"
|
44
|
+
),
|
25
45
|
]
|
26
46
|
)
|
27
47
|
}
|
28
48
|
)
|
29
49
|
end
|
50
|
+
|
30
51
|
let(:elasticache) do
|
31
52
|
scope = { "ec2_instance_id" => "some-ec2-instance-id" }
|
32
53
|
Aws::ElastiCache.new scope
|
33
54
|
end
|
34
55
|
|
35
|
-
let(:some_cache_node) { { :endpoint => { :address => "1.1.1.1", :port =>
|
36
|
-
let(:another_cache_node) { { :endpoint => { :address => "2.2.2.2", :port =>
|
56
|
+
let(:some_cache_node) { { :endpoint => { :address => "1.1.1.1", :port => 1111 } } }
|
57
|
+
let(:another_cache_node) { { :endpoint => { :address => "2.2.2.2", :port => 2222 } } }
|
58
|
+
let(:third_cache_node) { { :endpoint => { :address => "3.3.3.3", :port => 3333 } } }
|
59
|
+
let(:fourth_cache_node) { { :endpoint => { :address => "4.4.4.4", :port => 4444 } } }
|
37
60
|
|
38
|
-
|
61
|
+
let(:some_redis_cache_cluster) do
|
62
|
+
{
|
63
|
+
:cache_nodes => [some_cache_node, another_cache_node],
|
64
|
+
:engine => "redis",
|
65
|
+
:cache_cluster_status => "available",
|
66
|
+
:cache_cluster_create_time => time_earlier,
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:another_redis_cache_cluster) do
|
71
|
+
{
|
72
|
+
:cache_nodes => [third_cache_node, fourth_cache_node],
|
73
|
+
:engine => "redis",
|
74
|
+
:cache_cluster_status => "available",
|
75
|
+
:cache_cluster_create_time => time_later,
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:redis_cache_clusters) do
|
80
|
+
{
|
81
|
+
:cache_clusters => [some_redis_cache_cluster, another_redis_cache_cluster]
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
let(:some_memcache_cache_cluster) do
|
86
|
+
{
|
87
|
+
:cache_nodes => [some_cache_node, another_cache_node],
|
88
|
+
:engine => "memcached",
|
89
|
+
:cache_cluster_status => "available",
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
let(:another_memcache_cache_cluster) do
|
94
|
+
{
|
95
|
+
:cache_nodes => [third_cache_node, fourth_cache_node],
|
96
|
+
:engine => "memcached",
|
97
|
+
:cache_cluster_status => "available",
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
let(:memcache_cache_clusters) do
|
102
|
+
{
|
103
|
+
:cache_clusters => [some_memcache_cache_cluster, another_memcache_cache_cluster]
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
let(:all_cache_clusters) do
|
108
|
+
{
|
109
|
+
:cache_clusters => redis_cache_clusters[:cache_clusters] + memcache_cache_clusters[:cache_clusters],
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
let(:some_replication_group) do
|
114
|
+
{
|
115
|
+
:replication_group_id => "some-replication-group-id",
|
116
|
+
:node_groups => [{
|
117
|
+
:primary_endpoint => { :address => "some.replication.group.primary.endpoint", :port => 12_345 },
|
118
|
+
}],
|
119
|
+
:status => "available",
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
let(:another_replication_group) do
|
124
|
+
{
|
125
|
+
:replication_group_id => "another-replication-group-id",
|
126
|
+
:node_groups => [{
|
127
|
+
:primary_endpoint => { :address => "another.replication.group.primary.endpoint", :port => 23_456 },
|
128
|
+
}],
|
129
|
+
:status => "available",
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
let(:all_replication_groups) do
|
134
|
+
{
|
135
|
+
:replication_groups => [some_replication_group, another_replication_group]
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
before(:each) do
|
39
140
|
AWS::EC2.stub(:new => ec2_client)
|
40
141
|
AWS::CloudFormation.stub(:new => cfn_client)
|
142
|
+
@client = double
|
143
|
+
|
144
|
+
allow(@client).to receive(:describe_cache_clusters).and_return(all_cache_clusters)
|
145
|
+
|
146
|
+
allow(@client).to receive(:describe_cache_clusters).
|
147
|
+
with(
|
148
|
+
:cache_cluster_id => "some-redis-cluster-id",
|
149
|
+
:show_cache_node_info => true
|
150
|
+
).
|
151
|
+
and_return(:cache_clusters => [some_redis_cache_cluster])
|
152
|
+
|
153
|
+
allow(@client).to receive(:describe_cache_clusters).
|
154
|
+
with(
|
155
|
+
:cache_cluster_id => "another-redis-cluster-id",
|
156
|
+
:show_cache_node_info => true
|
157
|
+
).
|
158
|
+
and_return(:cache_clusters => [another_redis_cache_cluster])
|
159
|
+
|
160
|
+
allow(@client).to receive(:describe_cache_clusters).
|
161
|
+
with(
|
162
|
+
:cache_cluster_id => "some-memcache-cluster-id",
|
163
|
+
:show_cache_node_info => true
|
164
|
+
).
|
165
|
+
and_return(:cache_clusters => [some_memcache_cache_cluster])
|
166
|
+
|
167
|
+
allow(@client).to receive(:describe_cache_clusters).
|
168
|
+
with(
|
169
|
+
:cache_cluster_id => "another-memcache-cluster-id",
|
170
|
+
:show_cache_node_info => true
|
171
|
+
).
|
172
|
+
and_return(:cache_clusters => [another_memcache_cache_cluster])
|
173
|
+
|
174
|
+
allow(@client).to receive(:describe_replication_groups).
|
175
|
+
with(
|
176
|
+
:replication_group_id => "some-replication-group-id"
|
177
|
+
).
|
178
|
+
and_return(:replication_groups => [some_replication_group])
|
179
|
+
|
180
|
+
allow(@client).to receive(:describe_replication_groups).
|
181
|
+
with(
|
182
|
+
:replication_group_id => "another-replication-group-id"
|
183
|
+
).
|
184
|
+
and_return(:replication_groups => [another_replication_group])
|
185
|
+
|
186
|
+
allow(@client).to receive(:describe_replication_groups).with({}).and_return(all_replication_groups)
|
41
187
|
end
|
42
188
|
|
43
189
|
describe "#redis_cluster_nodes_for_cfn_stack" do
|
44
|
-
let(:cache_clusters) do
|
45
|
-
{
|
46
|
-
:cache_clusters => [{
|
47
|
-
:cache_nodes => [
|
48
|
-
some_cache_node,
|
49
|
-
another_cache_node
|
50
|
-
|
51
|
-
],
|
52
|
-
:engine => "redis"
|
53
|
-
}]
|
54
|
-
}
|
55
|
-
end
|
56
190
|
|
57
191
|
it "raises an exception when ec2_instance_id fact is missing" do
|
58
192
|
elasticache = Aws::ElastiCache.new
|
@@ -62,168 +196,81 @@ class Hiera
|
|
62
196
|
end
|
63
197
|
|
64
198
|
it "returns all Redis cluster nodes for CloudFormation stack of EC2 instance" do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
{ "endpoint" => { "address" => "
|
71
|
-
{ "endpoint" => { "address" => "2.2.2.2", "port" => 1234 } },
|
199
|
+
AWS::ElastiCache::Client.stub(:new => @client)
|
200
|
+
elasticache.redis_cluster_nodes_for_cfn_stack.should =~ [
|
201
|
+
{ "endpoint" => { "address" => "1.1.1.1", "port" => 1111 } },
|
202
|
+
{ "endpoint" => { "address" => "2.2.2.2", "port" => 2222 } },
|
203
|
+
{ "endpoint" => { "address" => "3.3.3.3", "port" => 3333 } },
|
204
|
+
{ "endpoint" => { "address" => "4.4.4.4", "port" => 4444 } },
|
72
205
|
]
|
73
206
|
end
|
74
207
|
end
|
75
208
|
|
76
209
|
describe "#redis_cluster_replica_groups_for_cfn_stack" do
|
77
|
-
let(:cache_clusters) do
|
78
|
-
{
|
79
|
-
:cache_clusters => [{
|
80
|
-
:cache_nodes => [
|
81
|
-
some_cache_node,
|
82
|
-
|
83
|
-
],
|
84
|
-
:replication_group_id => "some-group-id",
|
85
|
-
:engine => "redis",
|
86
|
-
}]
|
87
|
-
}
|
88
|
-
end
|
89
|
-
let(:replication_groups) do
|
90
|
-
{
|
91
|
-
:replication_groups => [{
|
92
|
-
:node_groups => [{
|
93
|
-
:primary_endpoint => { :address => "some.replication.group.primary.endpoint", :port => 1234 }
|
94
|
-
}]
|
95
|
-
}]
|
96
|
-
}
|
97
|
-
end
|
98
210
|
|
99
|
-
|
100
|
-
|
101
|
-
allow(client).to receive(:describe_cache_clusters).and_return(cache_clusters)
|
102
|
-
allow(client).to receive(:describe_replication_groups).with(:replication_group_id => "some-group-id").and_return(replication_groups)
|
103
|
-
AWS::ElastiCache::Client.stub(:new => client)
|
104
|
-
|
105
|
-
expect(elasticache.redis_cluster_replica_groups_for_cfn_stack).to eq [
|
106
|
-
{
|
107
|
-
"replication_group_id" => "some-group-id",
|
108
|
-
"primary_endpoint" => { "address" => "some.replication.group.primary.endpoint", "port" => 1234 }
|
109
|
-
},
|
110
|
-
]
|
211
|
+
let(:some_redis_cache_cluster) do
|
212
|
+
super().merge :replication_group_id => "some-replication-group-id"
|
111
213
|
end
|
112
214
|
|
113
215
|
context "multiple defined cache clusters are in the same replica group" do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
{
|
118
|
-
:cache_nodes => [
|
119
|
-
some_cache_node,
|
120
|
-
],
|
121
|
-
:replication_group_id => "some-group-id",
|
122
|
-
:engine => "redis",
|
123
|
-
},
|
124
|
-
{
|
125
|
-
:cache_nodes => [
|
126
|
-
another_cache_node,
|
127
|
-
],
|
128
|
-
:replication_group_id => "some-group-id",
|
129
|
-
:engine => "redis",
|
130
|
-
},
|
131
|
-
]
|
132
|
-
}
|
133
|
-
end
|
134
|
-
let(:replication_groups) do
|
135
|
-
{
|
136
|
-
:replication_groups => [{
|
137
|
-
:node_groups => [{
|
138
|
-
:primary_endpoint => { :address => "some.replication.group.primary.endpoint", :port => 1234 }
|
139
|
-
}]
|
140
|
-
}]
|
141
|
-
}
|
216
|
+
|
217
|
+
let(:another_redis_cache_cluster) do
|
218
|
+
super().merge :replication_group_id => "some-replication-group-id"
|
142
219
|
end
|
143
220
|
|
144
221
|
it "returns a deduplicated list of Redis replica groups" do
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
"replication_group_id" => "some-group-id",
|
153
|
-
"primary_endpoint" => { "address" => "some.replication.group.primary.endpoint", "port" => 1234 }
|
154
|
-
},
|
155
|
-
]
|
222
|
+
AWS::ElastiCache::Client.stub(:new => @client)
|
223
|
+
actual = elasticache.redis_cluster_replica_groups_for_cfn_stack
|
224
|
+
expect(actual.length).to be 1
|
225
|
+
expect(actual.first).to include(
|
226
|
+
"replication_group_id" => "some-replication-group-id",
|
227
|
+
"primary_endpoint" => { "address" => "some.replication.group.primary.endpoint", "port" => 12_345 }
|
228
|
+
)
|
156
229
|
end
|
157
230
|
end
|
158
231
|
|
159
|
-
context "
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
"some-stack-name" => double(
|
164
|
-
:resources => [
|
165
|
-
double(
|
166
|
-
:resource_type => "AWS::ElastiCache::CacheCluster",
|
167
|
-
:physical_resource_id => "some-cluster-id"
|
168
|
-
),
|
169
|
-
double(
|
170
|
-
:resource_type => "AWS::ElastiCache::CacheCluster",
|
171
|
-
:physical_resource_id => "another-cluster-id"
|
172
|
-
),
|
173
|
-
]
|
174
|
-
)
|
175
|
-
}
|
176
|
-
)
|
232
|
+
context "multiple defined cache clusters with different creation times are in the same replica group" do
|
233
|
+
|
234
|
+
let(:another_redis_cache_cluster) do
|
235
|
+
super().merge :replication_group_id => "some-replication-group-id"
|
177
236
|
end
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
]
|
190
|
-
},
|
191
|
-
"another-cluster-id" => {
|
192
|
-
:cache_clusters => [
|
193
|
-
{
|
194
|
-
:cache_nodes => [
|
195
|
-
another_cache_node,
|
196
|
-
],
|
197
|
-
:engine => "redis",
|
198
|
-
},
|
199
|
-
]
|
237
|
+
|
238
|
+
it "returns the most current cache cluster creation timestamp for the whole replication group in order to know which replica group is the most current" do
|
239
|
+
AWS::ElastiCache::Client.stub(:new => @client)
|
240
|
+
|
241
|
+
actual = elasticache.redis_cluster_replica_groups_for_cfn_stack
|
242
|
+
|
243
|
+
actual.should eq [
|
244
|
+
{
|
245
|
+
"replication_group_id" => "some-replication-group-id",
|
246
|
+
"primary_endpoint" => { "address" => "some.replication.group.primary.endpoint", "port" => 12_345 },
|
247
|
+
"latest_cache_cluster_create_time" => time_later.strftime("%s"),
|
200
248
|
}
|
201
|
-
|
202
|
-
end
|
203
|
-
let(:replication_groups) do
|
204
|
-
{
|
205
|
-
:replication_groups => [{
|
206
|
-
:node_groups => [{
|
207
|
-
:primary_endpoint => { :address => "some.replication.group.primary.endpoint", :port => 1234 }
|
208
|
-
}]
|
209
|
-
}]
|
210
|
-
}
|
249
|
+
]
|
211
250
|
end
|
251
|
+
end
|
252
|
+
|
253
|
+
context "two replica groups with one cache cluster each, one cache cluster being newer than the other" do
|
212
254
|
|
213
|
-
|
255
|
+
let(:another_redis_cache_cluster) do
|
256
|
+
super().merge :replication_group_id => "another-replication-group-id"
|
257
|
+
end
|
214
258
|
|
215
|
-
|
216
|
-
|
217
|
-
cache_clusters.fetch(options.fetch(:cache_cluster_id))
|
218
|
-
end
|
259
|
+
it "returns the most current cache cluster creation time for each replication group" do
|
260
|
+
AWS::ElastiCache::Client.stub(:new => @client)
|
219
261
|
|
220
|
-
|
221
|
-
AWS::ElastiCache::Client.stub(:new => client)
|
262
|
+
actual = elasticache.redis_cluster_replica_groups_for_cfn_stack
|
222
263
|
|
223
|
-
|
264
|
+
actual.should =~ [
|
265
|
+
{
|
266
|
+
"replication_group_id" => "some-replication-group-id",
|
267
|
+
"primary_endpoint" => { "address" => "some.replication.group.primary.endpoint", "port" => 12_345 },
|
268
|
+
"latest_cache_cluster_create_time" => time_earlier.strftime("%s"),
|
269
|
+
},
|
224
270
|
{
|
225
|
-
"replication_group_id" => "
|
226
|
-
"primary_endpoint" => { "address" => "
|
271
|
+
"replication_group_id" => "another-replication-group-id",
|
272
|
+
"primary_endpoint" => { "address" => "another.replication.group.primary.endpoint", "port" => 23_456 },
|
273
|
+
"latest_cache_cluster_create_time" => time_later.strftime("%s"),
|
227
274
|
},
|
228
275
|
]
|
229
276
|
end
|
@@ -238,27 +285,9 @@ class Hiera
|
|
238
285
|
end.to raise_error Aws::MissingFactError
|
239
286
|
end
|
240
287
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
:cache_clusters => [{
|
245
|
-
:cache_nodes => [
|
246
|
-
{ :endpoint => { :address => "3.3.3.3", :port => 5678 } },
|
247
|
-
{ :endpoint => { :address => "4.4.4.4", :port => 5678 } }
|
248
|
-
|
249
|
-
],
|
250
|
-
:engine => "memcached"
|
251
|
-
}]
|
252
|
-
}
|
253
|
-
end
|
254
|
-
|
255
|
-
it "returns all Memcached cluster nodes for CloudFormation stack of EC2 instance" do
|
256
|
-
client = double
|
257
|
-
allow(client).to receive(:describe_cache_clusters).and_return(cache_clusters)
|
258
|
-
AWS::ElastiCache::Client.stub(:new => client)
|
259
|
-
|
260
|
-
expect(elasticache.memcached_cluster_nodes_for_cfn_stack).to eq ["3.3.3.3", "4.4.4.4"]
|
261
|
-
end
|
288
|
+
it "returns all Memcached cluster nodes for CloudFormation stack of EC2 instance" do
|
289
|
+
AWS::ElastiCache::Client.stub(:new => @client)
|
290
|
+
elasticache.memcached_cluster_nodes_for_cfn_stack.should =~ ["1.1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"]
|
262
291
|
end
|
263
292
|
end
|
264
293
|
end
|
data/spec/aws_rds_spec.rb
CHANGED
@@ -10,18 +10,27 @@ class Hiera
|
|
10
10
|
:db_instances => [
|
11
11
|
{
|
12
12
|
:db_instance_identifier => "db1",
|
13
|
-
:endpoint
|
14
|
-
:engine
|
13
|
+
:endpoint => { :address => "db1.some-region.rds.amazonaws.com" },
|
14
|
+
:engine => "mysql",
|
15
|
+
:db_instance_status => "available",
|
15
16
|
},
|
16
17
|
{
|
17
18
|
:db_instance_identifier => "db2",
|
18
|
-
:endpoint
|
19
|
-
:engine
|
19
|
+
:endpoint => { :address => "db2.some-region.rds.amazonaws.com" },
|
20
|
+
:engine => "mysql",
|
21
|
+
:db_instance_status => "available",
|
20
22
|
},
|
21
23
|
{
|
22
24
|
:db_instance_identifier => "db3",
|
23
|
-
:endpoint
|
24
|
-
:engine
|
25
|
+
:endpoint => { :address => "db3.some-region.rds.amazonaws.com" },
|
26
|
+
:engine => "mysql",
|
27
|
+
:db_instance_status => "available",
|
28
|
+
},
|
29
|
+
{
|
30
|
+
:db_instance_identifier => "db4",
|
31
|
+
:endpoint => nil,
|
32
|
+
:engine => "mysql",
|
33
|
+
:db_instance_status => "modifying",
|
25
34
|
}
|
26
35
|
]
|
27
36
|
}
|
@@ -44,6 +53,12 @@ class Hiera
|
|
44
53
|
{ :key => "environment", :value => "production" },
|
45
54
|
{ :key => "role", :value => "mgmt-db" }
|
46
55
|
]
|
56
|
+
},
|
57
|
+
"arn:aws:rds:some-region:12345678:db:db4" => {
|
58
|
+
:tag_list => [
|
59
|
+
{ :key => "environment", :value => "production" },
|
60
|
+
{ :key => "role", :value => "mgmt-db" }
|
61
|
+
]
|
47
62
|
}
|
48
63
|
}
|
49
64
|
end
|
metadata
CHANGED
@@ -1,110 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiera-aws
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Mathias Lafeldt
|
8
8
|
- Deniz Adrian
|
9
9
|
- Soenke Ruempler
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
date: 2014-05-15 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
prerelease: false
|
16
18
|
name: aws-sdk
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
19
|
type: :runtime
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- &id002
|
23
|
+
- ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: "0"
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
23
28
|
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
requirements:
|
26
|
-
- - '>='
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: '0'
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
29
|
name: bundler
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - '>='
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '0'
|
36
30
|
type: :development
|
31
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- *id002
|
34
|
+
version_requirements: *id003
|
35
|
+
- !ruby/object:Gem::Dependency
|
37
36
|
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - '>='
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '0'
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
37
|
name: rake
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - '>='
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '0'
|
50
38
|
type: :development
|
39
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- *id002
|
42
|
+
version_requirements: *id004
|
43
|
+
- !ruby/object:Gem::Dependency
|
51
44
|
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - '>='
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '0'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
45
|
name: rspec
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - '>='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - '>='
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '0'
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: rubocop
|
73
|
-
requirement: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.21.0
|
78
46
|
type: :development
|
47
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- *id002
|
50
|
+
version_requirements: *id005
|
51
|
+
- !ruby/object:Gem::Dependency
|
79
52
|
prerelease: false
|
80
|
-
version_requirements: !ruby/object:Gem::Requirement
|
81
|
-
requirements:
|
82
|
-
- - ~>
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: 0.21.0
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
53
|
name: webmock
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - '>='
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '0'
|
92
54
|
type: :development
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
55
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- *id002
|
58
|
+
version_requirements: *id006
|
99
59
|
description: Hiera AWS Backend
|
100
|
-
email:
|
60
|
+
email:
|
101
61
|
- mathias.lafeldt@jimdo.com
|
102
62
|
- deniz.adrian@jimdo.com
|
103
63
|
- soenke.ruempler@jimdo.com
|
104
64
|
executables: []
|
65
|
+
|
105
66
|
extensions: []
|
67
|
+
|
106
68
|
extra_rdoc_files: []
|
107
|
-
|
69
|
+
|
70
|
+
files:
|
108
71
|
- .gitignore
|
109
72
|
- .rubocop.yml
|
110
73
|
- .travis.yml
|
@@ -125,30 +88,29 @@ files:
|
|
125
88
|
- spec/aws_rds_spec.rb
|
126
89
|
- spec/spec_helper.rb
|
127
90
|
homepage: https://github.com/Jimdo/hiera-aws
|
128
|
-
licenses:
|
91
|
+
licenses:
|
129
92
|
- Apache 2.0
|
130
93
|
metadata: {}
|
94
|
+
|
131
95
|
post_install_message:
|
132
96
|
rdoc_options: []
|
133
|
-
|
97
|
+
|
98
|
+
require_paths:
|
134
99
|
- lib
|
135
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
requirements:
|
142
|
-
- - '>='
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '0'
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- *id002
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- *id002
|
145
106
|
requirements: []
|
107
|
+
|
146
108
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.0.3
|
148
110
|
signing_key:
|
149
111
|
specification_version: 4
|
150
112
|
summary: Hiera AWS Backend
|
151
|
-
test_files:
|
113
|
+
test_files:
|
152
114
|
- spec/aws_backend_spec.rb
|
153
115
|
- spec/aws_base_spec.rb
|
154
116
|
- spec/aws_elasticache_spec.rb
|