kitchen-cloudformation 0.0.1 → 0.0.2

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: 82766a03521b8ae66cbd55c8595a99a6e6987251
4
- data.tar.gz: 469a2c828e14cf0e2d594b9a9f952640fff54878
3
+ metadata.gz: 94bea117ffbcbabd80f54b512bd221a0529781a0
4
+ data.tar.gz: af087f7fbc4f8bc816eb0d3f82394013b0d562e1
5
5
  SHA512:
6
- metadata.gz: 7e03b00da1ade35c0a48a8f20bc837684aba43551549ca24433e13e2530abb5ee5445b47bee1a03d7989fc7b7f041e38ca54b69c3a780b2dd081b5c757f2adbb
7
- data.tar.gz: 2dfb3564d3325a4aaff8ce535ebcf17c7b7617ed446ca95f8175ec61e2a7767e47186c74077870d8e6a8eb88fa09b183f12e97dca4fdd4837a260a813ced0c90
6
+ metadata.gz: f4ef72422a0c8266ec5e12c2b20746777e59916ff47d6249b67150e1f3975ebcb9c5e155c6a1b2a3ed0c1d83155704c35fc245498b0da2c9f1ea1a5a0b5ede38
7
+ data.tar.gz: b3c478beab03e5a4de1f44252f704ad15240c5ada1d9f387ba4c0c8f2359e00223806a1f83d839d0e6994875dcf77ed0d3d0380071eda4089dfc91df4ea15c50
data/README.md CHANGED
@@ -69,7 +69,6 @@ and it searches the following locations for a region:
69
69
  ENV['AWS_REGION']
70
70
  ```
71
71
 
72
-
73
72
  The first method attempted that works will be used. IE, if you want to auth
74
73
  using the instance profile, you must not set any of the access key configs
75
74
  or environment variables, and you must not specify a `~/.aws/credentials`
@@ -88,7 +87,7 @@ as per https://github.com/aws/aws-sdk-core-ruby/issues/93 .
88
87
  To overcome this problem set the parameter `ssl_cert_file` or the environment variable `SSL_CERT_FILE`
89
88
  to a a SSL CA bundle.
90
89
 
91
- A file ca-bundle.crt is supplied inside this gem for this purpose so you can set it to something like:
90
+ A file ca-bundle.crt is supplied inside this gem for this purpose so you can set it to something like:
92
91
  `<RubyHome>/lib/ruby/gems/2.1.0/gems/kitchen-cloudformation-0.0.1/ca-bundle.crt`
93
92
 
94
93
 
@@ -144,3 +143,8 @@ Apache 2.0 (see [LICENSE][license])
144
143
 
145
144
  -implement all the options of cloud formation.
146
145
 
146
+ -We also need plugins for:
147
+ OpenStack Heat
148
+ Azure Resource Manager
149
+ Google Cloud Deployment Manager
150
+ but i'm not aware of any ruby sdks for these yet.
@@ -1,26 +1,24 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "kitchen/driver/cloudformation_version.rb"
4
+ require 'kitchen/driver/cloudformation_version.rb'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "kitchen-cloudformation"
7
+ gem.name = 'kitchen-cloudformation'
8
8
  gem.version = Kitchen::Driver::CLOUDFORMATION_VERSION
9
- gem.license = "Apache 2.0"
10
- gem.authors = ["Neill Turner"]
11
- gem.email = ["neillwturner@gmail.com"]
12
- gem.description = "A Test Kitchen Driver for Amazon AWS CloudFormation"
9
+ gem.license = 'Apache 2.0'
10
+ gem.authors = ['Neill Turner']
11
+ gem.email = ['neillwturner@gmail.com']
12
+ gem.description = 'A Test Kitchen Driver for Amazon AWS CloudFormation'
13
13
  gem.summary = gem.description
14
- gem.homepage = "https://github.com/neillturner/kitchen-cloudformation"
15
- candidates = Dir.glob('{lib}/**/*') + ['README.md', 'CHANGELOG.md', 'LICENSE' , 'ca-bundle.crt', 'kitchen-cloudformation.gemspec']
14
+ gem.homepage = 'https://github.com/neillturner/kitchen-cloudformation'
15
+ candidates = Dir.glob('{lib}/**/*') + ['README.md', 'CHANGELOG.md', 'LICENSE', 'ca-bundle.crt', 'kitchen-cloudformation.gemspec']
16
16
  gem.files = candidates.sort
17
17
  gem.executables = []
18
- gem.require_paths = ["lib"]
19
-
20
- gem.add_dependency "test-kitchen", "~> 1.4"
21
- gem.add_dependency "excon"
22
- gem.add_dependency "multi_json"
23
- gem.add_dependency "aws-sdk-v1", "~> 1.59.0"
24
- gem.add_dependency "aws-sdk", "~> 2"
25
-
18
+ gem.require_paths = ['lib']
19
+ gem.add_dependency 'test-kitchen', '~> 1.4'
20
+ gem.add_dependency 'excon'
21
+ gem.add_dependency 'multi_json'
22
+ gem.add_dependency 'aws-sdk-v1', '~> 1.59.0'
23
+ gem.add_dependency 'aws-sdk', '~> 2'
26
24
  end
@@ -12,33 +12,31 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require "benchmark"
16
- require "json"
17
- require "aws"
18
- require "kitchen"
19
- require_relative "cloudformation_version"
20
- require_relative "aws/cf_client"
21
- require_relative "aws/stack_generator"
22
- #require "aws-sdk-core/waiters/errors"
15
+ require 'benchmark'
16
+ require 'json'
17
+ require 'aws'
18
+ require 'kitchen'
19
+ require_relative 'cloudformation_version'
20
+ require_relative 'aws/cf_client'
21
+ require_relative 'aws/stack_generator'
22
+ # require 'aws-sdk-core/waiters/errors'
23
23
 
24
24
  module Kitchen
25
-
26
25
  module Driver
27
-
26
+ #
28
27
  # Amazon CloudFormation driver for Test Kitchen.
29
28
  #
30
- class CloudFormation < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength
31
-
29
+ class CloudFormation < Kitchen::Driver::Base
32
30
  kitchen_driver_api_version 2
33
31
 
34
32
  plugin_version Kitchen::Driver::CLOUDFORMATION_VERSION
35
33
 
36
- default_config :region, ENV["AWS_REGION"] || "us-east-1"
37
- default_config :shared_credentials_profile, nil
34
+ default_config :region, ENV['AWS_REGION'] || 'us-east-1'
35
+ default_config :shared_credentials_profile, nil
38
36
  default_config :aws_access_key_id, nil
39
37
  default_config :aws_secret_access_key, nil
40
38
  default_config :aws_session_token, nil
41
- default_config :ssl_cert_file, ENV["SSL_CERT_FILE"]
39
+ default_config :ssl_cert_file, ENV['SSL_CERT_FILE']
42
40
  default_config :stack_name, nil
43
41
  default_config :template_file, nil
44
42
  default_config :parameters, {}
@@ -49,7 +47,7 @@ module Kitchen
49
47
  default_config :ssh_key, nil
50
48
  default_config :username, 'root'
51
49
  default_config :hostname, nil
52
- #default_config :interface, nil
50
+ # default_config :interface, nil
53
51
 
54
52
  required_config :ssh_key
55
53
  required_config :stack_name
@@ -67,14 +65,14 @@ module Kitchen
67
65
  END
68
66
  begin
69
67
  stack = create_stack
70
- rescue Exception => e
71
- error("CloudFormation #{e.message}.")
68
+ rescue # Exception => e
69
+ error("CloudFormation #{$ERROR_INFO}.") # e.message
72
70
  return
73
71
  end
74
72
  state[:stack_name] = stack.stack_name
75
73
  state[:hostname] = config[:hostname]
76
74
  info("Stack <#{state[:stack_name]}> requested.")
77
- #tag_stack(stack)
75
+ # tag_stack(stack)
78
76
 
79
77
  s = cf.get_stack(state[:stack_name])
80
78
  while s.stack_status == 'CREATE_IN_PROGRESS'
@@ -107,7 +105,7 @@ module Kitchen
107
105
  sleep(30)
108
106
  stack = cf.get_stack(state[:stack_name])
109
107
  end
110
- rescue Exception => e
108
+ rescue # Exception => e
111
109
  info("CloudFormation stack <#{state[:stack_name]}> deleted.")
112
110
  state.delete(:stack_name)
113
111
  return
@@ -122,8 +120,7 @@ module Kitchen
122
120
  config[:region],
123
121
  config[:shared_credentials_profile],
124
122
  config[:ssl_cert_file],
125
- config[:aws_access_key_id],
126
- config[:aws_secret_access_key],
123
+ { access_key_id: config[:aws_access_key_id], secret_access_key: config[:aws_secret_access_key] },
127
124
  config[:aws_session_token]
128
125
  )
129
126
  end
@@ -138,27 +135,18 @@ module Kitchen
138
135
  # can get rid of this when we get rid of these deprecated configs!
139
136
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
140
137
  def copy_deprecated_configs(state)
141
- if config[:ssh_timeout]
142
- state[:connection_timeout] = config[:ssh_timeout]
143
- end
144
- if config[:ssh_retries]
145
- state[:connection_retries] = config[:ssh_retries]
146
- end
147
- if config[:username]
148
- state[:username] = config[:username]
149
- #elsif instance.transport[:username] == instance.transport.class.defaults[:username]
150
- # # If the transport has the default username, copy it from amis.json
151
- # # This duplicated old behavior but I hate amis.json
152
- # ami_username = amis["usernames"][instance.platform.name]
153
- # state[:username] = ami_username if ami_username
154
- end
155
- if config[:ssh_key]
156
- state[:ssh_key] = config[:ssh_key]
157
- end
138
+ state[:connection_timeout] = config[:ssh_timeout] if config[:ssh_timeout]
139
+ state[:connection_retries] = config[:ssh_retries] if config[:ssh_retries]
140
+ state[:username] = config[:username] if config[:username]
141
+ # elsif instance.transport[:username] == instance.transport.class.defaults[:username]
142
+ # If the transport has the default username, copy it from amis.json
143
+ # This duplicated old behavior but I hate amis.json
144
+ # ami_username = amis["usernames"][instance.platform.name]
145
+ # state[:username] = ami_username if ami_username
146
+ # end
147
+ state[:ssh_key] = config[:ssh_key] if config[:ssh_key]
158
148
  end
159
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
160
149
 
161
- # Fog AWS helper for creating the stack
162
150
  def create_stack
163
151
  stack_data = stack_generator.cf_stack_data
164
152
  info("Creating CloudFormation Stack #{stack_data[:stack_name]}")
@@ -179,7 +167,6 @@ module Kitchen
179
167
  info("#{r[:timestamp]} #{r[:resource_type]} #{r[:logical_resource_id]} #{r[:resource_status]} #{r[:resource_status_reason]}")
180
168
  end
181
169
  end
182
-
183
170
  end
184
171
  end
185
172
  end
@@ -1,76 +1,73 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  #
3
3
  #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # Licensed under the Apache License, Version 2.0 (the 'License');
5
5
  # you may not use this file except in compliance with the License.
6
6
  # You may obtain a copy of the License at
7
7
  #
8
8
  # http://www.apache.org/licenses/LICENSE-2.0
9
9
  #
10
10
  # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # distributed under the License is distributed on an 'AS IS' BASIS,
12
12
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "aws-sdk"
17
- require "aws-sdk-core/credentials"
18
- require "aws-sdk-core/shared_credentials"
19
- require "aws-sdk-core/instance_profile_credentials"
16
+ require 'aws-sdk'
17
+ require 'aws-sdk-core/credentials'
18
+ require 'aws-sdk-core/shared_credentials'
19
+ require 'aws-sdk-core/instance_profile_credentials'
20
20
 
21
21
  module Kitchen
22
-
23
22
  module Driver
24
-
25
23
  class Aws
26
-
24
+ #
27
25
  # A class for creating and managing the Cloud Formation client connection
28
26
  #
29
27
  class CfClient
30
-
31
28
  def initialize(
32
29
  region,
33
30
  profile_name = nil,
34
31
  ssl_cert_file = nil,
35
- access_key_id = nil,
36
- secret_access_key = nil,
32
+ aws_key = {},
37
33
  session_token = nil
38
34
  )
35
+ access_key_id = aws_key[:access_key_id]
36
+ secret_access_key = aws_key[:secret_access_key]
39
37
  creds = self.class.get_credentials(
40
38
  profile_name, access_key_id, secret_access_key, session_token
41
39
  )
42
-
40
+
43
41
  ::AWS.config(
44
- :region => region,
45
- :credentials => creds,
46
- :ssl_ca_bundle => ssl_cert_file
42
+ region: region,
43
+ credentials: creds,
44
+ ssl_ca_bundle: ssl_cert_file
47
45
  )
48
46
  end
49
47
 
50
48
  # Try and get the credentials from an ordered list of locations
51
49
  # http://docs.aws.amazon.com/sdkforruby/api/index.html#Configuration
52
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
53
50
  def self.get_credentials(profile_name, access_key_id, secret_access_key, session_token)
54
- shared_creds = ::Aws::SharedCredentials.new(:profile_name => profile_name)
51
+ shared_creds = ::Aws::SharedCredentials.new(profile_name: profile_name)
55
52
  if access_key_id && secret_access_key
56
53
  ::Aws::Credentials.new(access_key_id, secret_access_key, session_token)
57
54
  # TODO: these are deprecated, remove them in the next major version
58
- elsif ENV["AWS_ACCESS_KEY"] && ENV["AWS_SECRET_KEY"]
55
+ elsif ENV['AWS_ACCESS_KEY'] && ENV['AWS_SECRET_KEY']
59
56
  ::Aws::Credentials.new(
60
- ENV["AWS_ACCESS_KEY"],
61
- ENV["AWS_SECRET_KEY"],
62
- ENV["AWS_TOKEN"]
57
+ ENV['AWS_ACCESS_KEY'],
58
+ ENV['AWS_SECRET_KEY'],
59
+ ENV['AWS_TOKEN']
63
60
  )
64
- elsif ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"]
61
+ elsif ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
65
62
  ::Aws::Credentials.new(
66
- ENV["AWS_ACCESS_KEY_ID"],
67
- ENV["AWS_SECRET_ACCESS_KEY"],
68
- ENV["AWS_SESSION_TOKEN"]
63
+ ENV['AWS_ACCESS_KEY_ID'],
64
+ ENV['AWS_SECRET_ACCESS_KEY'],
65
+ ENV['AWS_SESSION_TOKEN']
69
66
  )
70
67
  elsif shared_creds.loadable?
71
68
  shared_creds
72
69
  else
73
- ::Aws::InstanceProfileCredentials.new(:retries => 1)
70
+ ::Aws::InstanceProfileCredentials.new(retries: 1)
74
71
  end
75
72
  end
76
73
 
@@ -83,7 +80,7 @@ module Kitchen
83
80
  end
84
81
 
85
82
  def get_stack_events(stack_name)
86
- client.describe_stack_events({:stack_name => stack_name})
83
+ client.describe_stack_events(stack_name: stack_name)
87
84
  end
88
85
 
89
86
  def delete_stack(stack_name)
@@ -92,17 +89,13 @@ module Kitchen
92
89
  end
93
90
 
94
91
  def client
95
- @client ||= ::Aws::CloudFormation::Client.new
92
+ @client ||= ::Aws::CloudFormation::Client.new
96
93
  end
97
94
 
98
95
  def resource
99
96
  @resource ||= ::Aws::CloudFormation::Resource.new
100
97
  end
101
-
102
98
  end
103
-
104
99
  end
105
-
106
100
  end
107
-
108
101
  end
@@ -13,18 +13,15 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require "kitchen/logging"
16
+ require 'kitchen/logging'
17
17
 
18
18
  module Kitchen
19
-
20
19
  module Driver
21
-
22
20
  class Aws
23
-
21
+ #
24
22
  # A class for encapsulating the stack payload logic
25
23
  #
26
24
  class StackGenerator
27
-
28
25
  include Logging
29
26
 
30
27
  attr_reader :config, :cf
@@ -36,25 +33,21 @@ module Kitchen
36
33
 
37
34
  # Transform the provided config into the hash to send to AWS. Some fields
38
35
  # can be passed in null, others need to be ommitted if they are null
39
- def cf_stack_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
40
- s ={:stack_name => config[:stack_name]}
36
+ def cf_stack_data
37
+ s = { stack_name: config[:stack_name] }
41
38
  s[:template_url] = config[:template_url] if config[:template_file]
42
39
  if config[:template_file]
43
40
  s[:template_body] = File.open(config[:template_file], 'rb') { |file| file.read }
44
41
  end
45
- s[:timeout_in_minutes] = config[:timeout_in_minutes] if config[:timeout_in_minutes] != nil and config[:timeout_in_minutes]>0
46
- s[:disable_rollback] = config[:disable_rollback] if config[:disable_rollback] != nil and config[:disable_rollback] == true or config[:disable_rollback] == false
42
+ s[:timeout_in_minutes] = config[:timeout_in_minutes] if !config[:timeout_in_minutes].nil? && config[:timeout_in_minutes] > 0
43
+ s[:disable_rollback] = config[:disable_rollback] if !config[:disable_rollback].nil? && config[:disable_rollback] == true || config[:disable_rollback] == false
47
44
  s[:parameters] = []
48
- config[:parameters].each do |k,v|
49
- s[:parameters].push({:parameter_key => k.to_s, :parameter_value => v.to_s})
45
+ config[:parameters].each do |k, v|
46
+ s[:parameters].push(parameter_key: k.to_s, parameter_value: v.to_s)
50
47
  end
51
48
  s
52
49
  end
53
-
54
50
  end
55
-
56
51
  end
57
-
58
52
  end
59
-
60
53
  end
@@ -13,10 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module Kitchen
16
-
17
16
  module Driver
18
-
19
17
  # Version string for CloudFormation Test Kitchen driver
20
- CLOUDFORMATION_VERSION = "0.0.1"
18
+ CLOUDFORMATION_VERSION = '0.0.2'
21
19
  end
22
20
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-cloudformation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neill Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: excon
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: multi_json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: aws-sdk-v1
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.59.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.59.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: aws-sdk
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2'
83
83
  description: A Test Kitchen Driver for Amazon AWS CloudFormation
@@ -92,9 +92,9 @@ files:
92
92
  - README.md
93
93
  - ca-bundle.crt
94
94
  - kitchen-cloudformation.gemspec
95
+ - lib/kitchen/driver/CloudFormation.rb
95
96
  - lib/kitchen/driver/aws/cf_client.rb
96
97
  - lib/kitchen/driver/aws/stack_generator.rb
97
- - lib/kitchen/driver/cloud_formation.rb
98
98
  - lib/kitchen/driver/cloudformation_version.rb
99
99
  homepage: https://github.com/neillturner/kitchen-cloudformation
100
100
  licenses:
@@ -106,17 +106,17 @@ require_paths:
106
106
  - lib
107
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ">="
114
+ - - '>='
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.2.3
119
+ rubygems_version: 2.0.14
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: A Test Kitchen Driver for Amazon AWS CloudFormation