ecs_deploy_cli 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ecs_deploy_cli.rb +5 -1
  3. data/lib/ecs_deploy_cli/cli.rb +40 -2
  4. data/lib/ecs_deploy_cli/cloudformation/default.yml +411 -0
  5. data/lib/ecs_deploy_cli/dsl/auto_options.rb +17 -1
  6. data/lib/ecs_deploy_cli/dsl/cluster.rb +70 -0
  7. data/lib/ecs_deploy_cli/dsl/container.rb +8 -10
  8. data/lib/ecs_deploy_cli/dsl/parser.rb +9 -5
  9. data/lib/ecs_deploy_cli/dsl/service.rb +31 -2
  10. data/lib/ecs_deploy_cli/dsl/task.rb +2 -0
  11. data/lib/ecs_deploy_cli/runner.rb +26 -125
  12. data/lib/ecs_deploy_cli/runners/base.rb +105 -0
  13. data/lib/ecs_deploy_cli/runners/diff.rb +74 -0
  14. data/lib/ecs_deploy_cli/runners/logs.rb +14 -0
  15. data/lib/ecs_deploy_cli/runners/run_task.rb +27 -0
  16. data/lib/ecs_deploy_cli/runners/setup.rb +128 -0
  17. data/lib/ecs_deploy_cli/runners/ssh.rb +79 -0
  18. data/lib/ecs_deploy_cli/runners/status.rb +23 -0
  19. data/lib/ecs_deploy_cli/runners/update_crons.rb +41 -0
  20. data/lib/ecs_deploy_cli/runners/update_services.rb +55 -0
  21. data/lib/ecs_deploy_cli/runners/validate.rb +47 -0
  22. data/lib/ecs_deploy_cli/version.rb +3 -1
  23. data/spec/ecs_deploy_cli/cli_spec.rb +44 -4
  24. data/spec/ecs_deploy_cli/dsl/cluster_spec.rb +48 -0
  25. data/spec/ecs_deploy_cli/dsl/container_spec.rb +6 -4
  26. data/spec/ecs_deploy_cli/dsl/cron_spec.rb +2 -0
  27. data/spec/ecs_deploy_cli/dsl/parser_spec.rb +2 -0
  28. data/spec/ecs_deploy_cli/dsl/service_spec.rb +31 -0
  29. data/spec/ecs_deploy_cli/dsl/task_spec.rb +2 -0
  30. data/spec/ecs_deploy_cli/runner_spec.rb +177 -26
  31. data/spec/ecs_deploy_cli/runners/base_spec.rb +57 -0
  32. data/spec/spec_helper.rb +2 -3
  33. data/spec/support/ECSFile +13 -1
  34. data/spec/support/ECSFile.minimal +12 -0
  35. metadata +104 -13
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'aws-sdk-cloudwatchevents'
5
+ require 'aws-sdk-cloudwatchlogs'
6
+ require 'aws-sdk-ec2'
7
+ require 'aws-sdk-ssm'
8
+ require 'aws-sdk-cloudformation'
9
+
10
+ describe EcsDeployCli::Runners::Base do
11
+ let(:parser) { EcsDeployCli::DSL::Parser.load('spec/support/ECSFile') }
12
+ subject { described_class.new(parser) }
13
+ let(:mock_cf_client) { Aws::CloudFormation::Client.new(stub_responses: true) }
14
+ let(:mock_ssm_client) { Aws::SSM::Client.new(stub_responses: true) }
15
+ let(:mock_ecs_client) { Aws::ECS::Client.new(stub_responses: true) }
16
+ let(:mock_ec2_client) { Aws::EC2::Client.new(stub_responses: true) }
17
+ let(:mock_cwl_client) { Aws::CloudWatchLogs::Client.new(stub_responses: true) }
18
+ let(:mock_cwe_client) do
19
+ Aws::CloudWatchEvents::Client.new(stub_responses: true)
20
+ end
21
+
22
+ around(:each) do |example|
23
+ ENV['AWS_PROFILE_ID'] = '123123123'
24
+ ENV['AWS_REGION'] = 'us-east-1'
25
+ example.run
26
+ ENV['AWS_PROFILE_ID'] = nil
27
+ ENV['AWS_REGION'] = nil
28
+ end
29
+
30
+ context '#update_task' do
31
+ it 'creates cloud watch logs if missing' do
32
+ _, tasks, = parser.resolve
33
+
34
+ expect(mock_cwl_client).to receive(:describe_log_groups).at_least(:once).and_return({ log_groups: [] })
35
+ expect(mock_cwl_client).to receive(:create_log_group).at_least(:once)
36
+ expect(mock_ecs_client).to receive(:register_task_definition).at_least(:once).and_return({ task_definition: { family: 'some', revision: '1' } })
37
+
38
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:cwl_client).at_least(:once).and_return(mock_cwl_client)
39
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:ecs_client).at_least(:once).and_return(mock_ecs_client)
40
+
41
+ subject.update_task(tasks.values.first)
42
+ end
43
+
44
+ it 'creates no cloudwatch log group if is already there' do
45
+ _, tasks, = parser.resolve
46
+
47
+ expect(mock_cwl_client).to receive(:describe_log_groups).at_least(:once).and_return({ log_groups: [{}] })
48
+ expect(mock_cwl_client).not_to receive(:create_log_group)
49
+ expect(mock_ecs_client).to receive(:register_task_definition).at_least(:once).and_return({ task_definition: { family: 'some', revision: '1' } })
50
+
51
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:cwl_client).at_least(:once).and_return(mock_cwl_client)
52
+ expect_any_instance_of(EcsDeployCli::Runners::Base).to receive(:ecs_client).at_least(:once).and_return(mock_ecs_client)
53
+
54
+ subject.update_task(tasks.values.first)
55
+ end
56
+ end
57
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support'
2
4
  require 'rspec'
3
5
  require 'ecs_deploy_cli'
4
- # require 'kaminari-activerecord'
5
6
 
6
7
  I18n.enforce_available_locales = false
7
8
  RSpec::Expectations.configuration.warn_about_potential_false_positives = false
@@ -11,5 +12,3 @@ Dir[File.expand_path('../support/*.rb', __FILE__)].each { |f| require f }
11
12
  RSpec.configure do |config|
12
13
 
13
14
  end
14
-
15
-
data/spec/support/ECSFile CHANGED
@@ -4,7 +4,14 @@ aws_region ENV.fetch('AWS_REGION', 'eu-central-1')
4
4
  aws_profile_id ENV['AWS_PROFILE_ID']
5
5
 
6
6
  # Defining the cluster name
7
- cluster 'yourproject-cluster'
7
+ cluster 'yourproject-cluster' do
8
+ instance_type 't3.small'
9
+ keypair_name 'test'
10
+
11
+ vpc do
12
+ availability_zones 'eu-central-1a', 'eu-central-1b', 'eu-central-1c'
13
+ end
14
+ end
8
15
 
9
16
  # This is used as a template for the next two containers, it will not be used inside a task
10
17
  container :base_container do
@@ -49,6 +56,11 @@ end
49
56
  # The main service
50
57
  service :'yourproject-service' do
51
58
  task :yourproject
59
+ load_balancer :'yourproject-load-balancer' do
60
+ target_group_arn 'loader-target-group/123abc'
61
+ container_name :web
62
+ container_port 80
63
+ end
52
64
  end
53
65
 
54
66
  # A task for cron jobs
@@ -0,0 +1,12 @@
1
+ aws_region ENV.fetch('AWS_REGION', 'eu-central-1')
2
+
3
+ # Used to create ARNs
4
+ aws_profile_id '123123'
5
+
6
+ # Defining the cluster name
7
+ cluster 'yourproject-cluster'
8
+
9
+ # A container to exec cron jobs
10
+ container :cron do
11
+ command 'rails', 'runner'
12
+ end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_deploy_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mònade
8
8
  - ProGM
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2021-03-31 00:00:00.000000000 Z
@@ -31,6 +31,20 @@ dependencies:
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '7'
34
+ - !ruby/object:Gem::Dependency
35
+ name: aws-sdk-cloudformation
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
34
48
  - !ruby/object:Gem::Dependency
35
49
  name: aws-sdk-cloudwatchevents
36
50
  requirement: !ruby/object:Gem::Requirement
@@ -45,6 +59,20 @@ dependencies:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
61
  version: '1'
62
+ - !ruby/object:Gem::Dependency
63
+ name: aws-sdk-cloudwatchlogs
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1'
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
48
76
  - !ruby/object:Gem::Dependency
49
77
  name: aws-sdk-ec2
50
78
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +101,48 @@ dependencies:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
103
  version: '1'
104
+ - !ruby/object:Gem::Dependency
105
+ name: aws-sdk-ssm
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1'
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1'
118
+ - !ruby/object:Gem::Dependency
119
+ name: colorize
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.8.1
125
+ type: :runtime
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.8.1
132
+ - !ruby/object:Gem::Dependency
133
+ name: hashdiff
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.0'
139
+ type: :runtime
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.0'
76
146
  - !ruby/object:Gem::Dependency
77
147
  name: thor
78
148
  requirement: !ruby/object:Gem::Requirement
@@ -127,29 +197,46 @@ files:
127
197
  - lib/ecs-deploy-cli.rb
128
198
  - lib/ecs_deploy_cli.rb
129
199
  - lib/ecs_deploy_cli/cli.rb
200
+ - lib/ecs_deploy_cli/cloudformation/default.yml
130
201
  - lib/ecs_deploy_cli/dsl/auto_options.rb
202
+ - lib/ecs_deploy_cli/dsl/cluster.rb
131
203
  - lib/ecs_deploy_cli/dsl/container.rb
132
204
  - lib/ecs_deploy_cli/dsl/cron.rb
133
205
  - lib/ecs_deploy_cli/dsl/parser.rb
134
206
  - lib/ecs_deploy_cli/dsl/service.rb
135
207
  - lib/ecs_deploy_cli/dsl/task.rb
136
208
  - lib/ecs_deploy_cli/runner.rb
209
+ - lib/ecs_deploy_cli/runners/base.rb
210
+ - lib/ecs_deploy_cli/runners/diff.rb
211
+ - lib/ecs_deploy_cli/runners/logs.rb
212
+ - lib/ecs_deploy_cli/runners/run_task.rb
213
+ - lib/ecs_deploy_cli/runners/setup.rb
214
+ - lib/ecs_deploy_cli/runners/ssh.rb
215
+ - lib/ecs_deploy_cli/runners/status.rb
216
+ - lib/ecs_deploy_cli/runners/update_crons.rb
217
+ - lib/ecs_deploy_cli/runners/update_services.rb
218
+ - lib/ecs_deploy_cli/runners/validate.rb
137
219
  - lib/ecs_deploy_cli/version.rb
138
220
  - spec/ecs_deploy_cli/cli_spec.rb
221
+ - spec/ecs_deploy_cli/dsl/cluster_spec.rb
139
222
  - spec/ecs_deploy_cli/dsl/container_spec.rb
140
223
  - spec/ecs_deploy_cli/dsl/cron_spec.rb
141
224
  - spec/ecs_deploy_cli/dsl/parser_spec.rb
225
+ - spec/ecs_deploy_cli/dsl/service_spec.rb
142
226
  - spec/ecs_deploy_cli/dsl/task_spec.rb
143
227
  - spec/ecs_deploy_cli/runner_spec.rb
228
+ - spec/ecs_deploy_cli/runners/base_spec.rb
144
229
  - spec/spec_helper.rb
145
230
  - spec/support/ECSFile
231
+ - spec/support/ECSFile.minimal
146
232
  - spec/support/env_file.ext.yml
147
233
  - spec/support/env_file.yml
148
234
  homepage: https://rubygems.org/gems/ecs_deploy_cli
149
235
  licenses:
150
236
  - MIT
151
- metadata: {}
152
- post_install_message:
237
+ metadata:
238
+ source_code_uri: https://github.com/monade/ecs-deploy-cli
239
+ post_install_message:
153
240
  rdoc_options: []
154
241
  require_paths:
155
242
  - lib
@@ -164,18 +251,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
251
  - !ruby/object:Gem::Version
165
252
  version: '0'
166
253
  requirements: []
167
- rubygems_version: 3.2.7
168
- signing_key:
254
+ rubygems_version: 3.2.8
255
+ signing_key:
169
256
  specification_version: 4
170
257
  summary: A command line interface to make ECS deployments easier
171
258
  test_files:
259
+ - spec/ecs_deploy_cli/cli_spec.rb
260
+ - spec/ecs_deploy_cli/dsl/cluster_spec.rb
261
+ - spec/ecs_deploy_cli/dsl/container_spec.rb
262
+ - spec/ecs_deploy_cli/dsl/cron_spec.rb
263
+ - spec/ecs_deploy_cli/dsl/parser_spec.rb
264
+ - spec/ecs_deploy_cli/dsl/service_spec.rb
265
+ - spec/ecs_deploy_cli/dsl/task_spec.rb
266
+ - spec/ecs_deploy_cli/runner_spec.rb
267
+ - spec/ecs_deploy_cli/runners/base_spec.rb
172
268
  - spec/spec_helper.rb
173
269
  - spec/support/ECSFile
174
- - spec/support/env_file.yml
270
+ - spec/support/ECSFile.minimal
175
271
  - spec/support/env_file.ext.yml
176
- - spec/ecs_deploy_cli/runner_spec.rb
177
- - spec/ecs_deploy_cli/cli_spec.rb
178
- - spec/ecs_deploy_cli/dsl/task_spec.rb
179
- - spec/ecs_deploy_cli/dsl/parser_spec.rb
180
- - spec/ecs_deploy_cli/dsl/cron_spec.rb
181
- - spec/ecs_deploy_cli/dsl/container_spec.rb
272
+ - spec/support/env_file.yml