ecs_deployer 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 891da56bfba8142d032f86f8449d13db2deaa285
4
- data.tar.gz: dca591a305713ea2edd2bfeb6c06d9ba8510bf86
3
+ metadata.gz: f5c26195246ca8c3f6ea2e5e18d07683f6877200
4
+ data.tar.gz: e2555c0bf50ca13021c65c4ce71b78d9dbccf2e4
5
5
  SHA512:
6
- metadata.gz: fd8628ad1269511f1874fd32edf5cd91be91ce56646ada260d73ded00d86f3e29a6420d5a06c3db302ab10eddbb4477a68ca3f0cfc929c64ad2e31de58d4870a
7
- data.tar.gz: 6cc55eb4383a7cee8a11a8e826740b771d106cc6504c909fae39e1a1b6a0a314e147c8baa3cd0cf85f3b404b6147b6aa3aabc5769734744d2f33aca20bd8e378
6
+ metadata.gz: a46b2d802034be309114227942b54457940560b0a284d4a7e2c8c6ba271ab9eed2cb2d59fa52bb509a5ee4139778f90197be113c72fd82beb241331e5673ee9f
7
+ data.tar.gz: f8eb9fc6d6e05e57cf47ab0948802f4143016b19b30e6934de6f052c0fc9c8831d1eac47e5a1c1ddb43067ee4468b0da259113496477aef3a7f489712145045b
data/example/sample.rb CHANGED
@@ -2,7 +2,8 @@ require 'bundler/setup'
2
2
  require 'ecs_deployer'
3
3
 
4
4
  task_path = File.expand_path('./fixtures/task.yml', File.dirname(File.realpath(__FILE__)))
5
+ task_path = '/Users/naomichi_yamakita_pn082/Projects/sandbox-ecs/config/deploy/production.yml'
5
6
 
6
- ecs_deployer = EcsDeployer::Client.new
7
- ecs_deployer.register_task(task_path)
7
+ deployer = EcsDeployer::Client.new
8
+ deployer.register_task(task_path)
8
9
  # ecs_deployer.update_service('sandbox', 'production')
@@ -19,24 +19,26 @@ module EcsDeployer
19
19
  @revision = ''
20
20
  @new_task_definition_arn = ''
21
21
  @cli = Aws::ECS::Client.new(options)
22
+ @kms = Aws::KMS::Client.new(options)
22
23
  end
23
24
 
24
- # @param [String] task_path
25
+ # @param [String] path
25
26
  # @return [String]
26
- def register_task(task_path)
27
- raise IOError.new("File does not exist. [#{task_path}]") if !File.exist?(task_path)
28
- register_task_hash(YAML.load(File.read(task_path)))
27
+ def register_task(path)
28
+ raise IOError.new("File does not exist. [#{path}]") if !File.exist?(path)
29
+ register_task_hash(YAML.load(File.read(path)))
29
30
  end
30
31
 
31
- # @param [Hash] task_hash
32
+ # @param [Hash] task_definition
32
33
  # @return [String]
33
- def register_task_hash(task_hash)
34
- task_hash = Oj.load(Oj.dump(task_hash), symbol_keys: true)
34
+ def register_task_hash(task_definition)
35
+ task_definition = Oj.load(Oj.dump(task_definition), symbol_keys: true)
36
+ decrypt_environment_variables!(task_definition)
35
37
 
36
38
  result = @cli.register_task_definition({
37
- container_definitions: task_hash[:container_definitions],
38
- family: task_hash[:family],
39
- task_role_arn: task_hash[:task_role_arn]
39
+ container_definitions: task_definition[:container_definitions],
40
+ family: task_definition[:family],
41
+ task_role_arn: task_definition[:task_role_arn]
40
42
  })
41
43
 
42
44
  @family = result[:task_definition][:family]
@@ -86,6 +88,24 @@ module EcsDeployer
86
88
  end
87
89
 
88
90
  private
91
+ # @param [Hash] task_definition
92
+ def decrypt_environment_variables!(task_definition)
93
+ raise TaskDefinitionValidateError.new('\'container_definition\' is undefined.') unless task_definition.has_key?(:container_definitions)
94
+ task_definition[:container_definitions].each do |container_definition|
95
+ next unless container_definition.has_key?(:environment)
96
+
97
+ container_definition[:environment].each do |environment|
98
+ if match = environment[:value].match(/^\${(.+)}$/)
99
+ begin
100
+ environment[:value] = @kms.decrypt(ciphertext_blob: Base64.strict_decode64(match[1])).plaintext
101
+ rescue => e
102
+ raise KmsValidateError.new(e.to_s)
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+
89
109
  # @param [String] cluster
90
110
  # @param [String] service
91
111
  # @param [Fixnum] timeout
@@ -1,3 +1,3 @@
1
1
  module EcsDeployer
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
data/lib/ecs_deployer.rb CHANGED
@@ -6,5 +6,7 @@ require 'ecs_deployer/cli'
6
6
  module EcsDeployer
7
7
  class ServiceNotFoundError < EcsDeployer::Error; end
8
8
  class TaskNotFoundError < EcsDeployer::Error; end
9
+ class TaskDefinitionValidateError < EcsDeployer::Error; end
10
+ class KmsDecryptError < EcsDeployer::Error; end
9
11
  class DeployTimeoutError < EcsDeployer::Error; end
10
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - naomichi-y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2017-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: runtime_command
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.5.1
169
+ rubygems_version: 2.6.10
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Deploy application to ECS.