hako 2.4.0 → 2.5.0

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
  SHA256:
3
- metadata.gz: abb1bf796a54d7417e7f17bc3ff04a9fee504b4a7ad93a2ef40a7d3e8e12aa24
4
- data.tar.gz: 5c00e175b2e6e4868923966cd85193a56784f8863c90c0a36bd077ad538fd0a1
3
+ metadata.gz: 767220800b5dfd1061a252661ffbcbc906add32e8530ff6a995c0a7bd0ca8638
4
+ data.tar.gz: 2e55c3884f6fffd16c1be7c11d4d88bf25e92f8673d8879fe07bd0453fb60fb4
5
5
  SHA512:
6
- metadata.gz: d2ddc3d4a5b056fd2a2bfa2ac4bc81149ede6ef93310b5d1575c46e40faf7ca1c635ec20441fac1739d4d1212e1e002f4d88d0b390f7f255c3997ccecc8f51d6
7
- data.tar.gz: 81c559831ad9fbd2f46ae4e7596b92677c76e0bbe103c6d767d9745033409499854501254ddab16a14e8e223715067245dc8f1f1b9ebf820d873c07e89565a7c
6
+ metadata.gz: 240ca907d82750a600bcb21b94df017fc4b10732b78ede4e0025042957a0b0eadb3636512a0a4c0fdb59cff31ebb0e541da067397bad6a8da0ffb3a3293cfbec
7
+ data.tar.gz: c9949c11c16665d5efebe91e92acf30df5ae0c5cdd4d229e0f2b8711e503d5e43267aa233f6830ad6e24fba6f9bc8dbcd4c3a4e4efddb67c31d8861c8558cc4a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.5.0 (2018-11-22)
2
+ ## New features
3
+ - Add `load_balancer_name` and `target_group_name` option to skip creating ELB
4
+ - Support ECS secrets
5
+
1
6
  # 2.4.0 (2018-11-13)
2
7
  ## New features
3
8
  - Support `readonly_root_filesystem` parameter
@@ -1,6 +1,3 @@
1
- local fileProvider = std.native('provide.file');
2
- local provide(name) = fileProvider(std.toString({ path: 'hello.env' }), name);
3
-
4
1
  {
5
2
  scheduler: {
6
3
  type: 'ecs',
@@ -48,8 +45,11 @@ local provide(name) = fileProvider(std.toString({ path: 'hello.env' }), name);
48
45
  cpu: 256,
49
46
  env: {
50
47
  PORT: '3000',
51
- MESSAGE: std.format('%s-san', provide('username')),
52
48
  },
49
+ secrets: [{
50
+ name: 'MESSAGE',
51
+ value_from: 'arn:aws:ssm:ap-northeast-1:012345678901:parameter/hako/hello-lb-v2/secret-message',
52
+ }],
53
53
  },
54
54
  sidecars: {
55
55
  front: {
data/hako.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'aws-sdk-cloudwatch'
27
27
  spec.add_dependency 'aws-sdk-cloudwatchlogs'
28
28
  spec.add_dependency 'aws-sdk-ec2'
29
- spec.add_dependency 'aws-sdk-ecs', '>= 1.7.0'
29
+ spec.add_dependency 'aws-sdk-ecs', '>= 1.24.0'
30
30
  spec.add_dependency 'aws-sdk-elasticloadbalancing'
31
31
  spec.add_dependency 'aws-sdk-elasticloadbalancingv2'
32
32
  spec.add_dependency 'aws-sdk-s3'
@@ -46,6 +46,18 @@ module Hako
46
46
  @expanded_env ||= expand_env(@definition.fetch('env'))
47
47
  end
48
48
 
49
+ # @return [Array<Hash>, nil]
50
+ def secrets
51
+ if @definition['secrets']
52
+ @definition['secrets'].map do |secret|
53
+ {
54
+ name: secret.fetch('name'),
55
+ value_from: secret.fetch('value_from'),
56
+ }
57
+ end
58
+ end
59
+ end
60
+
49
61
  # @return [Array<Hash>]
50
62
  def port_mappings
51
63
  @definition['port_mappings'].map do |port_mapping|
@@ -155,7 +155,7 @@ module Hako
155
155
  task_definition = ecs_client.describe_task_definition(task_definition: current_service.task_definition).task_definition
156
156
  current_definition = "#{task_definition.family}:#{task_definition.revision}"
157
157
  target_definition = find_rollback_target(task_definition)
158
- Hako.logger.info "Current task defintion is #{current_definition}. Rolling back to #{target_definition}"
158
+ Hako.logger.info "Current task definition is #{current_definition}. Rolling back to #{target_definition}"
159
159
  call_rollback_started(task_definition, target_definition)
160
160
 
161
161
  if @dry_run
@@ -593,6 +593,7 @@ module Hako
593
593
  port_mappings: container.port_mappings,
594
594
  essential: true,
595
595
  environment: environment,
596
+ secrets: container.secrets,
596
597
  docker_labels: container.docker_labels,
597
598
  mount_points: container.mount_points,
598
599
  command: container.command,
@@ -1198,6 +1199,14 @@ module Hako
1198
1199
  cmd << "\\\n "
1199
1200
  end
1200
1201
  end
1202
+ (definition[:secrets] || []).each do |secret|
1203
+ name = secret.fetch(:name)
1204
+ # additional_env (given in command line) has priority over secrets (declared in definition file)
1205
+ unless additional_env.key?(name)
1206
+ cmd << '--env' << "#{name}=secret:#{secret.fetch(:value_from)}"
1207
+ cmd << "\\\n "
1208
+ end
1209
+ end
1201
1210
  additional_env.each do |name, value|
1202
1211
  cmd << '--env' << "#{name}=#{value}"
1203
1212
  cmd << "\\\n "
@@ -28,6 +28,7 @@ module Hako
28
28
  struct.member(:links, Schema::UnorderedArray.new(Schema::String.new))
29
29
  struct.member(:port_mappings, Schema::UnorderedArray.new(port_mapping_schema))
30
30
  struct.member(:environment, Schema::UnorderedArray.new(environment_schema))
31
+ struct.member(:secrets, Schema::Nullable.new(Schema::UnorderedArray.new(secrets_schema)))
31
32
  struct.member(:docker_labels, Schema::Table.new(Schema::String.new, Schema::String.new))
32
33
  struct.member(:mount_points, Schema::UnorderedArray.new(mount_point_schema))
33
34
  struct.member(:command, Schema::Nullable.new(Schema::OrderedArray.new(Schema::String.new)))
@@ -152,6 +153,13 @@ module Hako
152
153
  struct.member(:ip_address, Schema::String.new)
153
154
  end
154
155
  end
156
+
157
+ def secrets_schema
158
+ Schema::Structure.new.tap do |struct|
159
+ struct.member(:name, Schema::String.new)
160
+ struct.member(:value_from, Schema::String.new)
161
+ end
162
+ end
155
163
  end
156
164
  end
157
165
  end
@@ -99,7 +99,7 @@ module Hako
99
99
 
100
100
  # @return [String]
101
101
  def name
102
- "hako-#{@app_id}"
102
+ @elb_config.fetch('load_balancer_name', "hako-#{@app_id}")
103
103
  end
104
104
 
105
105
  # @return [Hash]
@@ -31,14 +31,14 @@ module Hako
31
31
 
32
32
  # @return [Aws::ElasticLoadBalancingV2::Types::LoadBalancer]
33
33
  def describe_load_balancer
34
- elb_client.describe_load_balancers(names: [name]).load_balancers[0]
34
+ elb_client.describe_load_balancers(names: [elb_name]).load_balancers[0]
35
35
  rescue Aws::ElasticLoadBalancingV2::Errors::LoadBalancerNotFound
36
36
  nil
37
37
  end
38
38
 
39
39
  # @return [Aws::ElasticLoadBalancingV2::Types::TargetGroup]
40
40
  def describe_target_group
41
- elb_client.describe_target_groups(names: [name]).target_groups[0]
41
+ elb_client.describe_target_groups(names: [target_group_name]).target_groups[0]
42
42
  rescue Aws::ElasticLoadBalancingV2::Errors::TargetGroupNotFound
43
43
  nil
44
44
  end
@@ -57,7 +57,7 @@ module Hako
57
57
  elb_type = @elb_v2_config.fetch('type', nil)
58
58
  if elb_type == 'network'
59
59
  load_balancer = elb_client.create_load_balancer(
60
- name: name,
60
+ name: elb_name,
61
61
  subnets: @elb_v2_config.fetch('subnets'),
62
62
  scheme: @elb_v2_config.fetch('scheme', nil),
63
63
  type: 'network',
@@ -66,7 +66,7 @@ module Hako
66
66
  Hako.logger.info "Created ELBv2(NLB) #{load_balancer.dns_name}"
67
67
  else
68
68
  load_balancer = elb_client.create_load_balancer(
69
- name: name,
69
+ name: elb_name,
70
70
  subnets: @elb_v2_config.fetch('subnets'),
71
71
  security_groups: @elb_v2_config.fetch('security_groups'),
72
72
  scheme: @elb_v2_config.fetch('scheme', nil),
@@ -82,7 +82,7 @@ module Hako
82
82
  elb_type = @elb_v2_config.fetch('type', nil)
83
83
  target_group = if elb_type == 'network'
84
84
  elb_client.create_target_group(
85
- name: name,
85
+ name: target_group_name,
86
86
  port: 80,
87
87
  protocol: 'TCP',
88
88
  vpc_id: @elb_v2_config.fetch('vpc_id'),
@@ -90,7 +90,7 @@ module Hako
90
90
  ).target_groups[0]
91
91
  else
92
92
  elb_client.create_target_group(
93
- name: name,
93
+ name: target_group_name,
94
94
  port: 80,
95
95
  protocol: 'HTTP',
96
96
  vpc_id: @elb_v2_config.fetch('vpc_id'),
@@ -203,7 +203,7 @@ module Hako
203
203
  Hako.logger.info "Deleted ELBv2 #{load_balancer.load_balancer_arn}"
204
204
  end
205
205
  else
206
- Hako.logger.info "ELBv2 #{name} doesn't exist"
206
+ Hako.logger.info "ELBv2 #{elb_name} doesn't exist"
207
207
  end
208
208
 
209
209
  target_group = describe_target_group
@@ -232,8 +232,13 @@ module Hako
232
232
  end
233
233
 
234
234
  # @return [String]
235
- def name
236
- "hako-#{@app_id}"
235
+ def elb_name
236
+ @elb_v2_config.fetch('load_balancer_name', "hako-#{@app_id}")
237
+ end
238
+
239
+ # @return [String]
240
+ def target_group_name
241
+ @elb_v2_config.fetch('target_group_name', elb_name)
237
242
  end
238
243
 
239
244
  # @return [Hash]
data/lib/hako/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hako
4
- VERSION = '2.4.0'
4
+ VERSION = '2.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hako
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-13 00:00:00.000000000 Z
11
+ date: 2018-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-applicationautoscaling
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.7.0
89
+ version: 1.24.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 1.7.0
96
+ version: 1.24.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: aws-sdk-elasticloadbalancing
99
99
  requirement: !ruby/object:Gem::Requirement