rebi 0.1.8 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1335da78cb996e8fae3fc14d605fc2adcb93c3bf
4
- data.tar.gz: 7299d451aa9a44d24e642501112fdc9309203a49
3
+ metadata.gz: 60cb77c8b19d62be65ae7300fa4096365bc6e073
4
+ data.tar.gz: aebf1f9224a7fc93716df58ce1b0318da92154de
5
5
  SHA512:
6
- metadata.gz: 7b19c033622bb14b79a04897c1e5a9ec5f80c312ebc86b48ddd9f8bbc06177701d083a82f1db2a1576f405df7ab8a814b6ee99815449ac31d1eedf5250a49449
7
- data.tar.gz: 12b99ae8f04ba6f1fe5c1dc375b0e1fd6df75d842d9531e5ab7cf77e647a506d591e5b149a2ae1d0739e015e7ffeec569cf0696551dd156e857e09850b26f05b
6
+ metadata.gz: edffd486287a4f1f4d8475b9de89a9edab64a8b7eb53e0fb4d895eef147a67f2856e22143b1e3cb7cb296954b43b42422caf54fed5a9b2bbcb928cb481bf125c
7
+ data.tar.gz: 6cb6b54a0d751f277dc2dbaf179c162262354487a1675708e9bfed7729d47cb917d91a07bed4a71aa73636cb460789bf3745c9b92b76af329e92deea01788178
data/README.md CHANGED
@@ -8,6 +8,7 @@ Deployment tool for Elasticbeanstalk
8
8
  - Multiple deployment
9
9
  - Deploy source code along with updating beanstalk options
10
10
  - Simple config
11
+ - Simple ssh
11
12
 
12
13
  ## Installation
13
14
  Or install it yourself as:
@@ -62,6 +63,12 @@ $ bundle exec rebi deploy development web
62
63
  $ bundle exec rebi deploy development
63
64
  ```
64
65
 
66
+ ### Ssh
67
+ ```bash
68
+ $ bundle exec rebi ssh development web
69
+ ```
70
+
71
+
65
72
  ### Get envronment variables and status
66
73
  ```bash
67
74
  # Running envronment variables
@@ -78,13 +85,22 @@ $ bundle exec rebi --help
78
85
  ```
79
86
 
80
87
  ### ERB in ebextensions config
81
- Use `rebi_env` to get environment variables config in .ebextensions
88
+ Use `rebi.env` to get environment variables config in .ebextensions
89
+ ```yaml
90
+ # Ex
91
+ # .ebextensions/00-envrionments.config
92
+ option_settings:
93
+ - option_name: KEY
94
+ value: <%= rebi.env[KEY] %>
95
+ ```
96
+
97
+ Use `rebi.opts` or `rebi.options` to get options config in .ebextensions
82
98
  ```yaml
83
99
  # Ex
84
100
  # .ebextensions/00-envrionments.config
85
101
  option_settings:
86
102
  - option_name: KEY
87
- value: <%= rebi_env[KEY] %>
103
+ value: <%= rebi.options.key %>
88
104
  ```
89
105
 
90
106
  ## Contributing
data/bin/rebi CHANGED
@@ -20,7 +20,7 @@ command :deploy do |c|
20
20
  c.description = 'Deploy single or multiple ElasticBeanstalk environments'
21
21
  c.example 'Deploy only web environment in development', 'rebi deploy development web'
22
22
  c.example 'Deploy all environments in development', 'rebi deploy development'
23
- c.option '--source-only', 'Deploy source only'
23
+ c.option '--include-settings', 'Deploy source and settings'
24
24
  c.option '--settings-only', 'Deploy option_settings and environment variables only'
25
25
  c.action do |args, options|
26
26
  stage, env_name = args
@@ -70,7 +70,7 @@ command :sample do |c|
70
70
  end
71
71
 
72
72
  command :terminate do |c|
73
- c.syntax = 'rebi terminate stage env_name '
73
+ c.syntax = 'rebi terminate stage env_name'
74
74
  c.description = 'Terminate environment'
75
75
  c.action do |args, options|
76
76
  stage, env_name = args
@@ -82,3 +82,23 @@ command :terminate do |c|
82
82
  end
83
83
  end
84
84
  end
85
+
86
+ command :list do |c|
87
+ c.syntax = 'rebi list'
88
+ c.description = "List all environments"
89
+ c.action do |args, options|
90
+ Rebi.app.print_list
91
+ end
92
+ end
93
+
94
+ command :ssh do |c|
95
+ c.syntax = 'rebi ssh stage env_name'
96
+ c.description = "Ssh into instance"
97
+ c.option '-s','--select', 'Get environment variables from config'
98
+ c.action do |args, options|
99
+ stage, env_name = args
100
+ raise Rebi::Error.new("Stage cannot be nil") if stage.blank?
101
+ raise Rebi::Error.new("Env name cannot be nil") if env_name.blank?
102
+ Rebi.app.ssh_interaction stage, env_name, options.__hash__
103
+ end
104
+ end
@@ -12,6 +12,7 @@ require 'erb'
12
12
  require 'ostruct'
13
13
  require 'thread'
14
14
  require 'thwait'
15
+ require 'subprocess'
15
16
 
16
17
  require 'rebi/erb_helper'
17
18
  require 'rebi/zip_helper'
@@ -20,6 +21,7 @@ require 'rebi/environment'
20
21
  require 'rebi/config'
21
22
  require 'rebi/config_environment'
22
23
  require 'rebi/error'
24
+ require 'rebi/ec2'
23
25
  require 'rebi/version'
24
26
 
25
27
  Dotenv.load
@@ -38,6 +40,14 @@ module Rebi
38
40
  @@client = c || Aws::ElasticBeanstalk::Client.new
39
41
  end
40
42
 
43
+ def ec2
44
+ @@ec2_client = Rebi::EC2.new
45
+ end
46
+
47
+ def iam
48
+ @@iam_client = Aws::IAM::Client.new
49
+ end
50
+
41
51
  def app
42
52
  return Rebi::Application.get_or_create_application(config.app_name)
43
53
  end
@@ -18,7 +18,7 @@ module Rebi
18
18
 
19
19
  def deploy stage_name, env_name=nil, opts={}
20
20
  return deploy_stage(stage_name, opts) if env_name.blank?
21
- env = Rebi::Environment.new stage_name, env_name, client
21
+ env = get_environment stage_name, env_name
22
22
  app_version = create_app_version env
23
23
  begin
24
24
  req_id = env.deploy app_version, opts
@@ -58,7 +58,7 @@ module Rebi
58
58
  return
59
59
  end
60
60
 
61
- env = Rebi::Environment.new stage_name, env_name, client
61
+ env = get_environment stage_name, env_name
62
62
  env_vars = from_config ? env.config.environment_variables : env.environment_variables
63
63
 
64
64
  Rebi.log("#{from_config ? "Config" : "Current"} environment variables", env.name)
@@ -77,7 +77,7 @@ module Rebi
77
77
  return
78
78
  end
79
79
 
80
- env = Rebi::Environment.new stage_name, env_name, client
80
+ env = get_environment stage_name, env_name
81
81
  env.check_created!
82
82
  Rebi.log("--------- CURRENT STATUS -------------", env.name)
83
83
  Rebi.log("id: #{env.id}", env.name)
@@ -87,7 +87,7 @@ module Rebi
87
87
  end
88
88
 
89
89
  def terminate! stage_name, env_name
90
- env = Rebi::Environment.new stage_name, env_name, client
90
+ env = get_environment stage_name, env_name
91
91
  begin
92
92
  req_id = env.terminate!
93
93
  ThreadsWait.all_waits(env.watch_request req_id) if req_id
@@ -123,6 +123,63 @@ module Rebi
123
123
  end
124
124
 
125
125
 
126
+ def print_list
127
+ others = []
128
+ configed = Hash.new {|h, k| h[k] = {} }
129
+ environments.each do |e|
130
+ if env_conf = Rebi.config.env_by_name(e.environment_name)
131
+ configed[env_conf.stage.to_s].merge! env_conf.env_name.to_s => env_conf.name
132
+ else
133
+ others << e.environment_name
134
+ end
135
+ end
136
+
137
+ configed.each do |stg, envs|
138
+ Rebi.log "-------------"
139
+ Rebi.log "#{stg.camelize}:"
140
+ envs.each do |k, v|
141
+ Rebi.log "\t#{k.camelize}: #{v}"
142
+ end
143
+ end
144
+
145
+ if others.present?
146
+ Rebi.log "-------------"
147
+ Rebi.log "Others:"
148
+ others.each do |e|
149
+ Rebi.log "\t- #{e}"
150
+ end
151
+ end
152
+ end
153
+
154
+ def ssh_interaction stage_name, env_name, opts={}
155
+ env = get_environment stage_name, env_name
156
+ instance_ids = env.instance_ids
157
+ return if instance_ids.empty?
158
+
159
+ instance_ids.each.with_index do |i,idx|
160
+ Rebi.log "#{idx+1}) #{i}"
161
+ end
162
+
163
+ instance_id = instance_ids.first
164
+
165
+ if instance_ids.count != 1 && opts[:select]
166
+
167
+
168
+ idx = 0
169
+ while idx < 1 || idx > instance_ids.count
170
+ idx = ask_for_integer "Select an instance to ssh into:"
171
+ end
172
+ instance_id = instance_ids[idx - 1]
173
+ end
174
+
175
+ Rebi.log "Preparing to ssh into [#{instance_id}]"
176
+ env.ssh instance_id
177
+ end
178
+
179
+ def get_environment stage_name, env_name
180
+ Rebi::Environment.new stage_name, env_name, client
181
+ end
182
+
126
183
  def self.client
127
184
  Rebi.client || Aws::ElasticBeanstalk::Client.new
128
185
  end
@@ -37,6 +37,21 @@ module Rebi
37
37
  return Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {})
38
38
  end
39
39
 
40
+ def env_by_name name
41
+ data[:stages].each do |stg_name, stg_conf|
42
+ stg = stage stg_name
43
+ stg_conf.keys.each do |env_name|
44
+ env_conf = Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {})
45
+ return env_conf if env_conf.name == name
46
+ end
47
+ end
48
+ return nil
49
+ end
50
+
51
+ def stages
52
+ data[:stages].keys
53
+ end
54
+
40
55
  private
41
56
  def data
42
57
  @data ||= YAML::load(ERB.new(IO.read(config_file)).result).with_indifferent_access
@@ -12,14 +12,15 @@ module Rebi
12
12
  :instance_type,
13
13
  :instance_num,
14
14
  :key_name,
15
- :service_role,
15
+ :instance_profile,
16
16
  :ebextensions,
17
17
  :solution_stack_name,
18
18
  :cfg_file,
19
19
  :env_file,
20
20
  :environment_variables,
21
21
  :option_settings,
22
- :raw_conf
22
+ :raw_conf,
23
+ :options
23
24
 
24
25
  NAMESPACE ={
25
26
  app_env: "aws:elasticbeanstalk:application:environment",
@@ -39,6 +40,8 @@ module Rebi
39
40
  eb_env: [:ServiceRole],
40
41
  }
41
42
 
43
+ DEFAULT_IAM_INSTANCE_PROFILE = "aws-elasticbeanstalk-ec2-role"
44
+
42
45
  def initialize stage, env_name, env_conf={}
43
46
  @raw_conf = env_conf.with_indifferent_access
44
47
  @stage = stage.to_sym
@@ -107,8 +110,17 @@ module Rebi
107
110
  get_opt(ns[:autoscaling_launch], :EC2KeyName)
108
111
  end
109
112
 
110
- def service_role
111
- get_opt(ns[:eb_env], :ServiceRole)
113
+ def instance_profile
114
+ get_opt(ns[:autoscaling_launch], :IamInstanceProfile)
115
+ end
116
+
117
+ def default_instance_profile?
118
+ self.instance_profile == DEFAULT_IAM_INSTANCE_PROFILE
119
+ end
120
+
121
+ def options
122
+ opts = (raw_conf[:options] || {}).with_indifferent_access
123
+ JSON.parse(opts.to_json, object_class: OpenStruct)
112
124
  end
113
125
 
114
126
  def cfg_file
@@ -133,7 +145,7 @@ module Rebi
133
145
  end
134
146
 
135
147
  def solution_stack_name
136
- @solution_stack_name ||= raw_conf[:solution_stack_name] || "64bit Amazon Linux 2017.03 v2.4.1 running Ruby 2.3 (Puma)"
148
+ @solution_stack_name ||= raw_conf[:solution_stack_name] || "64bit Amazon Linux 2017.09 v2.6.0 running Ruby 2.4 (Puma)"
137
149
  end
138
150
 
139
151
  def platform_arn
@@ -201,7 +213,7 @@ module Rebi
201
213
  opt = set_opt_keyname opt
202
214
  opt = set_opt_instance_type opt
203
215
  opt = set_opt_instance_num opt
204
- opt = set_opt_service_role opt
216
+ opt = set_opt_instance_profile opt
205
217
 
206
218
  return @opt = opt
207
219
  end
@@ -237,17 +249,18 @@ module Rebi
237
249
  return opt
238
250
  end
239
251
 
240
- def set_opt_service_role opt
241
- s_role = if raw_conf.key?(:service_role)
242
- raw_conf[:service_role]
243
- elsif role = get_raw_opt(ns[:eb_env], :ServiceRole)
252
+ def set_opt_instance_profile opt
253
+ s_role = if raw_conf.key?(:instance_profile)
254
+ raw_conf[:instance_profile]
255
+ elsif role = get_raw_opt(ns[:autoscaling_launch], :IamInstanceProfile)
244
256
  role
245
257
  else
246
- 'aws-elasticbeanstalk-service-role'
258
+ DEFAULT_IAM_INSTANCE_PROFILE
247
259
  end
260
+
248
261
  if s_role.present?
249
- opt[ns[:eb_env]].merge!({
250
- ServiceRole: s_role,
262
+ opt[ns[:autoscaling_launch]].merge!({
263
+ IamInstanceProfile: s_role,
251
264
  }.with_indifferent_access)
252
265
  end
253
266
  return opt
@@ -0,0 +1,59 @@
1
+ module Rebi
2
+ class EC2
3
+
4
+ attr_reader :client
5
+
6
+ def initialize client=Aws::EC2::Client.new
7
+ @client = client
8
+ end
9
+
10
+ def describe_instance instance_id
11
+ res = client.describe_instances instance_ids: [instance_id]
12
+ return res.reservations.first.instances.first
13
+ end
14
+
15
+ def authorize_ssh instance_id, &blk
16
+ group_id = describe_instance(instance_id).security_groups.map(&:group_id).sort.first
17
+
18
+ my_ip = `dig +short myip.opendns.com @resolver1.opendns.com`.chomp
19
+ cidr_ip = my_ip.present? ? "#{my_ip}/32" : "0.0.0.0/0"
20
+
21
+ begin
22
+ log "Attempting to open port 22."
23
+ client.authorize_security_group_ingress({
24
+ group_id: group_id,
25
+ ip_protocol: "tcp",
26
+ to_port: 22,
27
+ from_port: 22,
28
+ cidr_ip: cidr_ip
29
+ })
30
+ log "SSH port 22 open."
31
+
32
+ rescue Aws::EC2::Errors::InvalidPermissionDuplicate
33
+ log "Opened already"
34
+ rescue Exception => e
35
+ raise e
36
+ end
37
+
38
+ yield if block_given?
39
+
40
+ ensure
41
+ begin
42
+ log "Attempting to close port 22."
43
+ client.revoke_security_group_ingress({
44
+ group_id: group_id,
45
+ ip_protocol: "tcp",
46
+ to_port: 22,
47
+ from_port: 22,
48
+ cidr_ip: cidr_ip
49
+ })
50
+ rescue Exception => e
51
+ raise e
52
+ end
53
+ end
54
+
55
+ def log mes
56
+ Rebi.log(mes, "EC2")
57
+ end
58
+ end
59
+ end
@@ -143,7 +143,11 @@ module Rebi
143
143
  end
144
144
  log ("Timeout") unless finished
145
145
  end
146
- thread.join
146
+ begin
147
+ thread.join
148
+ rescue Interrupt
149
+ log("Interrupt")
150
+ end
147
151
  return thread
148
152
  end
149
153
 
@@ -160,9 +164,17 @@ module Rebi
160
164
  return self
161
165
  end
162
166
 
167
+ def instance_ids
168
+ resp = client.describe_environment_resources environment_name: self.name
169
+ resp.environment_resources.instances.map(&:id).sort
170
+ end
171
+
163
172
  def init version_label, opts={}
164
173
  log("Creating new environment")
165
174
  start_time = Time.now
175
+
176
+ self.check_instance_profile
177
+
166
178
  self.api_data = client.create_environment({
167
179
  application_name: config.app_name,
168
180
  cname_prefix: config.cname_prefix,
@@ -183,6 +195,7 @@ module Rebi
183
195
  end
184
196
 
185
197
  def update version_label, opts={}
198
+
186
199
  raise Rebi::Error::EnvironmentInUpdating.new(name) if in_updating?
187
200
  log("Start updating")
188
201
  start_time = Time.now
@@ -192,15 +205,19 @@ module Rebi
192
205
  environment_name: config.name,
193
206
  version_label: version_label,
194
207
  description: config.description,
195
- option_settings: deploy_opts[:option_settings],
196
- options_to_remove: deploy_opts[:options_to_remove],
197
208
  }
198
209
 
199
- if opts[:source_only]
200
- deploy_args.delete(:option_settings)
201
- deploy_args.delete(:options_to_remove)
202
- elsif opts[:settings_only]
203
- deploy_args.delete(:version_label)
210
+ if opts[:include_settings] || opts[:settings_only]
211
+ deploy_args.merge!({
212
+ option_settings: deploy_opts[:option_settings],
213
+ options_to_remove: deploy_opts[:options_to_remove],
214
+ })
215
+ deploy_args.delete(:version_label) if opts[:settings_only]
216
+ else
217
+ deploy_args.merge!({
218
+ option_settings: deploy_opts[:env_only],
219
+ options_to_remove: deploy_opts[:options_to_remove],
220
+ })
204
221
  end
205
222
 
206
223
  self.api_data = client.update_environment(deploy_args)
@@ -267,21 +284,104 @@ module Rebi
267
284
  def gen_deploy_opts
268
285
  to_deploy = []
269
286
  to_remove = []
287
+ env_only = []
270
288
  config.opts_array.each do |o|
271
289
  o = o.deep_dup
272
- if o[:namespace] == config.ns(:app_env) && o[:value].blank?
273
- o.delete(:value)
274
- to_remove << o
275
- next
290
+
291
+ if o[:namespace] == config.ns(:app_env)
292
+ if o[:value].blank?
293
+ o.delete(:value)
294
+ to_remove << o
295
+ next
296
+ else
297
+ env_only << o
298
+ end
276
299
  end
277
300
  to_deploy << o
278
301
  end
279
302
  return {
280
303
  option_settings: to_deploy,
281
304
  options_to_remove: to_remove,
305
+ env_only: env_only,
282
306
  }
283
307
  end
284
308
 
309
+ def ssh instance_id
310
+ raise "Invalid instance_id" unless self.instance_ids.include?(instance_id)
311
+
312
+
313
+ instance = Rebi.ec2.describe_instance instance_id
314
+
315
+ raise Rebi::Error::EC2NoKey.new unless instance.key_name.present?
316
+ raise Rebi::Error::EC2NoIP.new unless instance.public_ip_address.present?
317
+
318
+
319
+ Rebi.ec2.authorize_ssh instance_id do
320
+ user = "ec2-user"
321
+ key_file = "~/.ssh/#{instance.key_name}.pem"
322
+ raise Rebi::Error::KeyFileNotFound unless File.exists? File.expand_path(key_file)
323
+ cmd = "ssh -i #{key_file} #{user}@#{instance.public_ip_address}"
324
+ log cmd
325
+
326
+ begin
327
+ Subprocess.check_call(['ssh', '-i', key_file, "#{user}@#{instance.public_ip_address}"])
328
+ rescue Subprocess::NonZeroExit => e
329
+ log e.message
330
+ end
331
+
332
+ end
333
+
334
+ end
335
+
336
+ def check_instance_profile
337
+ iam = Rebi.iam
338
+ begin
339
+ iam.get_instance_profile({
340
+ instance_profile_name: config.instance_profile
341
+ })
342
+ return true
343
+ rescue Aws::IAM::Errors::NoSuchEntity => e
344
+ raise e unless config.default_instance_profile?
345
+ self.create_defaut_profile
346
+ end
347
+ end
348
+
349
+ def create_defaut_profile
350
+ iam = Rebi.iam
351
+ profile = role = Rebi::ConfigEnvironment::DEFAULT_IAM_INSTANCE_PROFILE
352
+ iam.create_instance_profile({
353
+ instance_profile_name: profile
354
+ })
355
+
356
+ document = <<-JSON
357
+ {
358
+ "Version":"2008-10-17",
359
+ "Statement":[
360
+ {
361
+ "Effect":"Allow",
362
+ "Principal":{
363
+ "Service":["ec2.amazonaws.com"]
364
+ },
365
+ "Action":["sts:AssumeRole"]
366
+ }
367
+ ]
368
+ }
369
+ JSON
370
+ begin
371
+ iam.create_role({
372
+ role_name: role,
373
+ assume_role_policy_document: document
374
+ })
375
+ rescue Aws::IAM::Errors::EntityAlreadyExists
376
+ end
377
+
378
+ iam.add_role_to_instance_profile({
379
+ instance_profile_name: profile,
380
+ role_name: role
381
+ })
382
+
383
+ end
384
+
285
385
  def self.create stage_name, env_name, version_label, client
286
386
  env = new stage_name, env_name, client
287
387
  raise Rebi::Error::EnvironmentExisted.new if env.created?
@@ -291,7 +391,7 @@ module Rebi
291
391
  end
292
392
 
293
393
  # TODO
294
- def self.all client=Rebi.client
394
+ def self.all app_name, client=Rebi.client
295
395
  client.describe_environments(application_name: app_name,
296
396
  include_deleted: false).environments
297
397
  end
@@ -1,14 +1,23 @@
1
1
  module Rebi
2
2
  class ErbHelper
3
- def initialize input, env_vars
3
+ def initialize input, env_conf
4
4
  @input = input
5
- @env = env_vars || {}
5
+ @env = env_conf.environment_variables || {}
6
+ @options = env_conf.options
6
7
  end
7
8
 
8
9
  def rebi_env k=nil
9
10
  k.present? ? @env[k] : @env
10
11
  end
11
12
 
13
+ def rebi
14
+ OpenStruct.new ({
15
+ env: @env,
16
+ opts: @options,
17
+ options: @options,
18
+ })
19
+ end
20
+
12
21
  def result
13
22
  ERB.new(@input).result(binding)
14
23
  end
@@ -9,5 +9,9 @@ module Rebi
9
9
  NoGit = Class.new(self)
10
10
  ServiceError = Class.new(self)
11
11
  EnvironmentInUpdating = Class.new(self)
12
+ EC2NoKey = Class.new(self)
13
+ EC2NoIP = Class.new(self)
14
+ KeyFileNotFound = Class.new(self)
15
+ SSH = Class.new(self)
12
16
  end
13
17
  end
@@ -0,0 +1,43 @@
1
+ # module Rebi
2
+ # class IAM
3
+ #
4
+ # attr_reader :client
5
+ #
6
+ # def initialize client=Aws::IAM::Client.new
7
+ # @client = client
8
+ # end
9
+ #
10
+ # def check_or_create_eb_profile profile
11
+ #
12
+ # end
13
+ #
14
+ # def create_instance_profile profile
15
+ # clieng.create_instance_profile({
16
+ # instance_profile_name: profile
17
+ # })
18
+ # end
19
+ #
20
+ # def get_default_role
21
+ # role = Rebi::ConfigEnvironment::DEFAULT_IAM_INSTANCE_PROFILE
22
+ # document = '{"Version": "2008-10-17","Statement": [{"Action":' \
23
+ # ' "sts:AssumeRole","Principal": {"Service": ' \
24
+ # '"ec2.amazonaws.com"},"Effect": "Allow","Sid": ""}]}'
25
+ # client.create_role({
26
+ # role_name: role,
27
+ # assume_role_policy_document: document
28
+ # })
29
+ # return role
30
+ # end
31
+ #
32
+ # def add_role_to_profile profile, role
33
+ # client.add_role_to_instance_profile({
34
+ # instance_profile_name: profile,
35
+ # role_name: role
36
+ # })
37
+ # end
38
+ #
39
+ # def log mes
40
+ # Rebi.log(mes, "IAM")
41
+ # end
42
+ # end
43
+ # end
@@ -1,3 +1,3 @@
1
1
  module Rebi
2
- VERSION = '0.1.8'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -36,7 +36,7 @@ module Rebi
36
36
  ebextensions.each do |ex_folder|
37
37
  Dir.glob("#{ex_folder}/*.config") do |fname|
38
38
  next unless (File.file?(fname) && files.include?(fname))
39
- next unless y = YAML::load(ErbHelper.new(File.read(fname), env_conf.environment_variables).result)
39
+ next unless y = YAML::load(ErbHelper.new(File.read(fname), env_conf).result)
40
40
  basename = File.basename(fname)
41
41
  target = ".ebextensions/#{basename}"
42
42
  tmp_yaml = "#{tmp_folder}/#{basename}"
@@ -13,8 +13,9 @@ stages: #Required: Hash
13
13
  min: 1
14
14
  max: 1
15
15
  key_name: # Optional, if not set you cannot ssh into ec2 instances
16
- service_role: role # Optional, default: aws-elasticbeanstalk-service-role
17
- solution_stack_name: Ruby # Optional: default: "64bit Amazon Linux 2017.03 v2.4.1 running Ruby 2.3 (Puma)"
16
+ instance_profile: iam_profile # Optional, default: aws-elasticbeanstalk-service-role
17
+ # http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-instanceprofile.html
18
+ solution_stack_name: Ruby # Optional: default: "64bit Amazon Linux 2017.09 v2.6.0 running Ruby 2.4 (Puma)"
18
19
  env_file: .env.development # Optional
19
20
  environment_variables: # Optional, nil will be deleted when update,
20
21
  # Use `rebi get_env stage --from-config` to get env settings
@@ -32,6 +33,8 @@ stages: #Required: Hash
32
33
  # Result will has 01.config, 02.config(from web1_extensions) and 03.config
33
34
  cfg_file: File path or cfg name # Optional
34
35
 
36
+ options: #Hash, Other custom options for using in erb
37
+ use_basic: true # rebi.opts.use_basic
35
38
  worker:
36
39
  # ...
37
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rebi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - KhiemNS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-23 00:00:00.000000000 Z
11
+ date: 2017-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '4.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: subprocess
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.3'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.3'
97
111
  description: Deploy ElasticBeanstalk with multiple deploy, switchable and dynamic
98
112
  generated ebextensions with erb
99
113
  email:
@@ -111,9 +125,11 @@ files:
111
125
  - lib/rebi/application.rb
112
126
  - lib/rebi/config.rb
113
127
  - lib/rebi/config_environment.rb
128
+ - lib/rebi/ec2.rb
114
129
  - lib/rebi/environment.rb
115
130
  - lib/rebi/erb_helper.rb
116
131
  - lib/rebi/error.rb
132
+ - lib/rebi/iam.rb
117
133
  - lib/rebi/version.rb
118
134
  - lib/rebi/zip_helper.rb
119
135
  - lib/tasks/rebi.rake