geoengineer 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/geoengineer/cli/geo_cli.rb +16 -5
- data/lib/geoengineer/cli/status_command.rb +38 -46
- data/lib/geoengineer/cli/terraform_commands.rb +8 -2
- data/lib/geoengineer/environment.rb +5 -1
- data/lib/geoengineer/resource.rb +54 -35
- data/lib/geoengineer/resources/aws_cloudwatch_metric_alarm.rb +48 -0
- data/lib/geoengineer/resources/aws_iam_account_password_policy.rb +32 -0
- data/lib/geoengineer/resources/aws_iam_instance_profile.rb +28 -0
- data/lib/geoengineer/resources/aws_iam_policy.rb +5 -5
- data/lib/geoengineer/resources/aws_iam_user.rb +3 -3
- data/lib/geoengineer/resources/aws_kms_key.rb +27 -0
- data/lib/geoengineer/resources/aws_lambda_function.rb +3 -0
- data/lib/geoengineer/resources/aws_lambda_permission.rb +24 -18
- data/lib/geoengineer/resources/aws_ses_receipt_rule.rb +2 -2
- data/lib/geoengineer/resources/aws_ses_receipt_rule_set.rb +2 -2
- data/lib/geoengineer/resources/aws_sns_topic.rb +3 -3
- data/lib/geoengineer/resources/aws_sns_topic_subscription.rb +17 -6
- data/lib/geoengineer/resources/aws_sqs_queue.rb +3 -3
- data/lib/geoengineer/template.rb +3 -0
- data/lib/geoengineer/utils/aws_clients.rb +7 -0
- data/lib/geoengineer/version.rb +1 -1
- data/spec/resource_spec.rb +119 -18
- data/spec/resources/aws_cloudwatch_metric_alarm_spec.rb +38 -0
- data/spec/resources/aws_iam_account_password_policy_spec.rb +51 -0
- data/spec/resources/aws_iam_instance_profile_spec.rb +40 -0
- data/spec/resources/aws_kinesis_stream_spec.rb +1 -0
- data/spec/resources/aws_kms_key_spec.rb +44 -0
- data/spec/resources/aws_lambda_permission_spec.rb +0 -38
- metadata +17 -5
- metadata.gz.sig +0 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe "GeoEngineer::Resources::AwsCloudwatchMetricAlarm" do
|
4
|
+
let(:aws_client) { AwsClients.cloudwatch }
|
5
|
+
|
6
|
+
before { aws_client.setup_stubbing }
|
7
|
+
common_resource_tests(
|
8
|
+
GeoEngineer::Resources::AwsCloudwatchMetricAlarm,
|
9
|
+
'aws_cloudwatch_metric_alarm'
|
10
|
+
)
|
11
|
+
|
12
|
+
let(:alarm_name) { 'some-fake-alarm' }
|
13
|
+
|
14
|
+
describe '#_fetch_remote_resources' do
|
15
|
+
before do
|
16
|
+
aws_client.stub_responses(
|
17
|
+
:describe_alarms,
|
18
|
+
{
|
19
|
+
metric_alarms: [
|
20
|
+
{ alarm_name: alarm_name },
|
21
|
+
{ alarm_name: 'another-alarm-name' }
|
22
|
+
]
|
23
|
+
}
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should create an array of hashes from the AWS response' do
|
28
|
+
resources = GeoEngineer::Resources::AwsCloudwatchMetricAlarm._fetch_remote_resources
|
29
|
+
expect(resources.count).to eql 2
|
30
|
+
|
31
|
+
test_cloudalarm = resources.first
|
32
|
+
|
33
|
+
expect(test_cloudalarm[:alarm_name]).to eql(alarm_name)
|
34
|
+
expect(test_cloudalarm[:_geo_id]).to eql(alarm_name)
|
35
|
+
expect(test_cloudalarm[:_terraform_id]).to eql(alarm_name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe 'GeoEngineer::Resources::AwsIamAccountPasswordPolicy' do
|
4
|
+
let(:aws_client) { AwsClients.iam }
|
5
|
+
|
6
|
+
before { aws_client.setup_stubbing }
|
7
|
+
|
8
|
+
let(:iam_password_policy) do
|
9
|
+
GeoEngineer::Resources::AwsIamAccountPasswordPolicy
|
10
|
+
.new('aws_iam_account_password_policy', 'fake_password_policy') {
|
11
|
+
allow_users_to_change_password true
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
common_resource_tests(
|
16
|
+
GeoEngineer::Resources::AwsIamAccountPasswordPolicy,
|
17
|
+
'aws_iam_account_password_policy',
|
18
|
+
false
|
19
|
+
)
|
20
|
+
|
21
|
+
let(:password_policy_params) do
|
22
|
+
{ require_symbols: true,
|
23
|
+
require_numbers: true,
|
24
|
+
require_uppercase_characters: true,
|
25
|
+
require_lowercase_characters: true,
|
26
|
+
allow_users_to_change_password: true,
|
27
|
+
expire_passwords: true,
|
28
|
+
max_password_age: 365,
|
29
|
+
password_reuse_prevention: 6 }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#remote_resource_params' do
|
33
|
+
before do
|
34
|
+
aws_client.stub_responses(
|
35
|
+
:get_account_password_policy,
|
36
|
+
{
|
37
|
+
password_policy: password_policy_params
|
38
|
+
}
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should create a hash from the remote resource' do
|
43
|
+
singleton_id = GeoEngineer::Resources::AwsIamAccountPasswordPolicy::SINGLETON_ID
|
44
|
+
|
45
|
+
expected_params = password_policy_params.merge({ _geo_id: singleton_id,
|
46
|
+
_terraform_id: singleton_id })
|
47
|
+
|
48
|
+
expect(iam_password_policy.remote_resource_params).to eql(expected_params)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe("GeoEngineer::Resources::AwsIamInstanceProfile") do
|
4
|
+
let(:aws_client) { AwsClients.iam }
|
5
|
+
|
6
|
+
before do
|
7
|
+
aws_client.setup_stubbing
|
8
|
+
end
|
9
|
+
|
10
|
+
common_resource_tests(
|
11
|
+
GeoEngineer::Resources::AwsIamInstanceProfile,
|
12
|
+
'aws_iam_instance_profile'
|
13
|
+
)
|
14
|
+
|
15
|
+
describe "#_fetch_remote_resources" do
|
16
|
+
before do
|
17
|
+
aws_client.stub_responses(
|
18
|
+
:list_instance_profiles,
|
19
|
+
{
|
20
|
+
instance_profiles:
|
21
|
+
[
|
22
|
+
{
|
23
|
+
instance_profile_name: "test",
|
24
|
+
instance_profile_id: "test",
|
25
|
+
arn: "arn:aws:iam::1234567890:instance-profile/test",
|
26
|
+
path: "/",
|
27
|
+
create_date: Time.new,
|
28
|
+
roles: []
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should create list of profiles from returned AWS SDK' do
|
36
|
+
remote_resources = GeoEngineer::Resources::AwsIamInstanceProfile._fetch_remote_resources
|
37
|
+
expect(remote_resources.length).to eq 1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -35,6 +35,7 @@ describe("GeoEngineer::Resources::AwsKinesisStream") do
|
|
35
35
|
stream_name: "test",
|
36
36
|
stream_arn: "arn:aws:kinesis:us-east-1:1234567890:stream/test",
|
37
37
|
stream_status: "ACTIVE",
|
38
|
+
stream_creation_timestamp: Time.now,
|
38
39
|
shards: [],
|
39
40
|
has_more_shards: false,
|
40
41
|
retention_period_hours: 24,
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe "GeoEngineer::Resources::AwsKmsKey" do
|
5
|
+
let(:aws_client) { AwsClients.kms }
|
6
|
+
|
7
|
+
before { aws_client.setup_stubbing }
|
8
|
+
common_resource_tests(GeoEngineer::Resources::AwsKmsKey, 'aws_kms_key')
|
9
|
+
|
10
|
+
let(:key_geo_id) { 'myid' }
|
11
|
+
let(:key_id) { 'some-key-id' }
|
12
|
+
|
13
|
+
describe '#_fetch_remote_resources' do
|
14
|
+
before do
|
15
|
+
aws_client.stub_responses(
|
16
|
+
:list_keys,
|
17
|
+
{
|
18
|
+
keys: [
|
19
|
+
{ key_id: key_id }
|
20
|
+
]
|
21
|
+
}
|
22
|
+
)
|
23
|
+
aws_client.stub_responses(
|
24
|
+
:describe_key,
|
25
|
+
{
|
26
|
+
key_metadata: {
|
27
|
+
key_id: key_id,
|
28
|
+
description: key_geo_id
|
29
|
+
}
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should create an array of hashes from the AWS response' do
|
35
|
+
resources = GeoEngineer::Resources::AwsKmsKey._fetch_remote_resources
|
36
|
+
expect(resources.count).to eql 1
|
37
|
+
|
38
|
+
test_key = resources.first
|
39
|
+
|
40
|
+
expect(test_key[:_geo_id]).to eql(key_geo_id)
|
41
|
+
expect(test_key[:_terraform_id]).to eql(key_id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -49,42 +49,4 @@ describe GeoEngineer::Resources::AwsLambdaPermission do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
53
|
-
describe '#_deep_symbolize_keys' do
|
54
|
-
let(:simple_obj) { JSON.parse({ foo: "bar", baz: "qux" }.to_json) }
|
55
|
-
let(:complex_obj) do
|
56
|
-
JSON.parse(
|
57
|
-
{
|
58
|
-
foo: {
|
59
|
-
bar: {
|
60
|
-
baz: [
|
61
|
-
{ qux: "quack" }
|
62
|
-
]
|
63
|
-
}
|
64
|
-
},
|
65
|
-
bar: [
|
66
|
-
{ foo: "bar" },
|
67
|
-
nil,
|
68
|
-
[{ baz: "qux" }],
|
69
|
-
1,
|
70
|
-
"baz"
|
71
|
-
]
|
72
|
-
}.to_json
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "converts top level keys to symbols" do
|
77
|
-
expect(simple_obj.keys.include?(:foo)).to eq(false)
|
78
|
-
expect(simple_obj.keys.include?("foo")).to eq(true)
|
79
|
-
converted = described_class._deep_symbolize_keys(simple_obj)
|
80
|
-
expect(converted.keys.include?(:foo)).to eq(true)
|
81
|
-
expect(converted.keys.include?("foo")).to eq(false)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "converts deeply nested keys to symbols" do
|
85
|
-
converted = described_class._deep_symbolize_keys(complex_obj)
|
86
|
-
expect(converted[:foo][:bar][:baz].first[:qux]).to eq("quack")
|
87
|
-
expect(converted[:bar].first[:foo]).to eq("bar")
|
88
|
-
end
|
89
|
-
end
|
90
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoengineer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- coinbase
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
6WK7/7ziN7oP5gOag1gEqjCieZEtmPdj2uvE5+X0/bQOpstnZfPbeaMxswFdxMB4
|
31
31
|
gvJWIT9xvxqnL8bM/44RAGrzrkx7OQi5HEoMCpfXJevlu1PF17Y3ylbNGBL4Og==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2017-
|
33
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rspec
|
@@ -159,19 +159,19 @@ dependencies:
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0.7'
|
161
161
|
- !ruby/object:Gem::Dependency
|
162
|
-
name:
|
162
|
+
name: parallel
|
163
163
|
requirement: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
165
|
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
|
-
version: '1.
|
167
|
+
version: '1.10'
|
168
168
|
type: :runtime
|
169
169
|
prerelease: false
|
170
170
|
version_requirements: !ruby/object:Gem::Requirement
|
171
171
|
requirements:
|
172
172
|
- - "~>"
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: '1.
|
174
|
+
version: '1.10'
|
175
175
|
description: |2
|
176
176
|
GeoEngineer provides a Ruby DSL and command line tool (geo)
|
177
177
|
to codeify then plan and execute changes to cloud resources using Hashicorp Terraform.
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/geoengineer/resources/aws_cloudtrail.rb
|
197
197
|
- lib/geoengineer/resources/aws_cloudwatch_event_rule.rb
|
198
198
|
- lib/geoengineer/resources/aws_cloudwatch_event_target.rb
|
199
|
+
- lib/geoengineer/resources/aws_cloudwatch_metric_alarm.rb
|
199
200
|
- lib/geoengineer/resources/aws_customer_gateway.rb
|
200
201
|
- lib/geoengineer/resources/aws_db_instance.rb
|
201
202
|
- lib/geoengineer/resources/aws_db_parameter_group.rb
|
@@ -207,8 +208,10 @@ files:
|
|
207
208
|
- lib/geoengineer/resources/aws_elasticache_subnet_group.rb
|
208
209
|
- lib/geoengineer/resources/aws_elasticsearch_domain.rb
|
209
210
|
- lib/geoengineer/resources/aws_elb.rb
|
211
|
+
- lib/geoengineer/resources/aws_iam_account_password_policy.rb
|
210
212
|
- lib/geoengineer/resources/aws_iam_group.rb
|
211
213
|
- lib/geoengineer/resources/aws_iam_group_membership.rb
|
214
|
+
- lib/geoengineer/resources/aws_iam_instance_profile.rb
|
212
215
|
- lib/geoengineer/resources/aws_iam_policy.rb
|
213
216
|
- lib/geoengineer/resources/aws_iam_policy_attachment.rb
|
214
217
|
- lib/geoengineer/resources/aws_iam_role.rb
|
@@ -217,6 +220,7 @@ files:
|
|
217
220
|
- lib/geoengineer/resources/aws_instance.rb
|
218
221
|
- lib/geoengineer/resources/aws_internet_gateway.rb
|
219
222
|
- lib/geoengineer/resources/aws_kinesis_stream.rb
|
223
|
+
- lib/geoengineer/resources/aws_kms_key.rb
|
220
224
|
- lib/geoengineer/resources/aws_lambda_alias.rb
|
221
225
|
- lib/geoengineer/resources/aws_lambda_event_source_mapping.rb
|
222
226
|
- lib/geoengineer/resources/aws_lambda_function.rb
|
@@ -272,6 +276,7 @@ files:
|
|
272
276
|
- spec/resources/aws_cloudtrail_spec.rb
|
273
277
|
- spec/resources/aws_cloudwatch_event_rule_spec.rb
|
274
278
|
- spec/resources/aws_cloudwatch_event_target_spec.rb
|
279
|
+
- spec/resources/aws_cloudwatch_metric_alarm_spec.rb
|
275
280
|
- spec/resources/aws_customer_gateway_spec.rb
|
276
281
|
- spec/resources/aws_db_instance_spec.rb
|
277
282
|
- spec/resources/aws_db_parameter_group_spec.rb
|
@@ -283,8 +288,10 @@ files:
|
|
283
288
|
- spec/resources/aws_elasticcache_parameter_group_spec.rb
|
284
289
|
- spec/resources/aws_elasticsearch_domain_spec.rb
|
285
290
|
- spec/resources/aws_elb_spec.rb
|
291
|
+
- spec/resources/aws_iam_account_password_policy_spec.rb
|
286
292
|
- spec/resources/aws_iam_group_membership_spec.rb
|
287
293
|
- spec/resources/aws_iam_group_spec.rb
|
294
|
+
- spec/resources/aws_iam_instance_profile_spec.rb
|
288
295
|
- spec/resources/aws_iam_policy_attachment_spec.rb
|
289
296
|
- spec/resources/aws_iam_policy_spec.rb
|
290
297
|
- spec/resources/aws_iam_role_spec.rb
|
@@ -293,6 +300,7 @@ files:
|
|
293
300
|
- spec/resources/aws_instance_spec.rb
|
294
301
|
- spec/resources/aws_internet_gateway_spec.rb
|
295
302
|
- spec/resources/aws_kinesis_stream_spec.rb
|
303
|
+
- spec/resources/aws_kms_key_spec.rb
|
296
304
|
- spec/resources/aws_lambda_alias_spec.rb
|
297
305
|
- spec/resources/aws_lambda_event_source_mapping_spec.rb
|
298
306
|
- spec/resources/aws_lambda_function_spec.rb
|
@@ -370,6 +378,7 @@ test_files:
|
|
370
378
|
- spec/resources/aws_cloudtrail_spec.rb
|
371
379
|
- spec/resources/aws_cloudwatch_event_rule_spec.rb
|
372
380
|
- spec/resources/aws_cloudwatch_event_target_spec.rb
|
381
|
+
- spec/resources/aws_cloudwatch_metric_alarm_spec.rb
|
373
382
|
- spec/resources/aws_customer_gateway_spec.rb
|
374
383
|
- spec/resources/aws_db_instance_spec.rb
|
375
384
|
- spec/resources/aws_db_parameter_group_spec.rb
|
@@ -381,8 +390,10 @@ test_files:
|
|
381
390
|
- spec/resources/aws_elasticcache_parameter_group_spec.rb
|
382
391
|
- spec/resources/aws_elasticsearch_domain_spec.rb
|
383
392
|
- spec/resources/aws_elb_spec.rb
|
393
|
+
- spec/resources/aws_iam_account_password_policy_spec.rb
|
384
394
|
- spec/resources/aws_iam_group_membership_spec.rb
|
385
395
|
- spec/resources/aws_iam_group_spec.rb
|
396
|
+
- spec/resources/aws_iam_instance_profile_spec.rb
|
386
397
|
- spec/resources/aws_iam_policy_attachment_spec.rb
|
387
398
|
- spec/resources/aws_iam_policy_spec.rb
|
388
399
|
- spec/resources/aws_iam_role_spec.rb
|
@@ -391,6 +402,7 @@ test_files:
|
|
391
402
|
- spec/resources/aws_instance_spec.rb
|
392
403
|
- spec/resources/aws_internet_gateway_spec.rb
|
393
404
|
- spec/resources/aws_kinesis_stream_spec.rb
|
405
|
+
- spec/resources/aws_kms_key_spec.rb
|
394
406
|
- spec/resources/aws_lambda_alias_spec.rb
|
395
407
|
- spec/resources/aws_lambda_event_source_mapping_spec.rb
|
396
408
|
- spec/resources/aws_lambda_function_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|