cfer 0.6.2 → 0.7.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
- SHA1:
3
- metadata.gz: 05b80c1775b880a3b92953f25ab31b863ba7ed3b
4
- data.tar.gz: 3d8c82a4fc20c18d6af7edbe2085d3413e6676ca
2
+ SHA256:
3
+ metadata.gz: 629fe44ee8569e44618d1697d3d466eda739d5181dde1b694741bfd09ead4c4a
4
+ data.tar.gz: db78bef95f3c77f7ab97bd66febb40cd8a56b660621afa70ad2d37fa9f86017c
5
5
  SHA512:
6
- metadata.gz: 989ac1ceb29703cb5fc3e4cc17c0bfef537fcb29b1bf73cbcecd1376cf6ede2c6950fe08f581649f9a585174c7159781b32eb7a780a63c454195cf747301d998
7
- data.tar.gz: 7a172c3d7e7ed3bab8d7efc4a3e561fd98cb59d748a3e0df23dde00f3b225d004f2e048d586cb628fde1acb59531ce58a266d6bf60dd2597627e0088bf84f48b
6
+ metadata.gz: b8ecbc6a69a00c6f318ef52078a30a90f797ff6eda558e1c3ce8a90497e98b1cc8297d9b03b7379a87dc97eaaecc67d7873690ae3fc4098de0a75b8b999adcb2
7
+ data.tar.gz: 0c3fe1e3c6c53988b2d83d418655ab37446e99baeb402d3744f5e8c3b14f320b045f6a4cd6b7648cbb04f0b30a3811128b9f7f7aad3501e696a2b93ef168f083
@@ -1,8 +1,11 @@
1
1
  language: ruby
2
2
  install: bundle install --without debug --jobs=3 --retry=3
3
3
  rvm:
4
- - 2.2.5
5
- - 2.3.0
4
+ - 2.2
5
+ - 2.3
6
+ - 2.4
7
+ - 2.5
8
+ - 2.6
6
9
  - ruby-head
7
10
  matrix:
8
11
  allow_failures:
@@ -1,14 +1,5 @@
1
1
  # Cfer Change Log
2
2
 
3
- ## 0.6.2
4
- ### Bugfixes
5
- * Fixes a Cri compatibility issue, which should have gone out in 0.6.1
6
-
7
- ## 0.6.1
8
- ### Bugfixes
9
- * Fixes an issue with version pinning of Docile. Docile 1.3 makes breaking changes, so Cfer now pins Docile 1.1.*
10
- * Removes Yard version specification. There's no particular need to pin yard to a version, and Github reported security problems with the old version.
11
-
12
3
  ## 0.6.0
13
4
 
14
5
  ### Enhancements
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ group :test do
8
8
  gem 'rspec-mocks'
9
9
  gem 'guard-rspec'
10
10
  gem 'simplecov'
11
- gem 'rubocop', '~> 0.47.1'
11
+ gem 'rubocop', '~> 0.51'
12
12
  gem "codeclimate-test-reporter", "~> 1.0.0"
13
13
  end
14
14
 
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'docile', '~> 1.1.5'
25
25
  spec.add_runtime_dependency 'cri', '~> 2.7'
26
26
  spec.add_runtime_dependency 'activesupport', '>= 3'
27
- spec.add_runtime_dependency 'aws-sdk', '~> 2.2'
28
- spec.add_runtime_dependency 'aws-sdk-resources', '~> 2.2'
27
+ spec.add_runtime_dependency 'aws-sdk', '~> 2'
28
+ spec.add_runtime_dependency 'aws-sdk-resources', '~> 2'
29
29
  spec.add_runtime_dependency 'preconditions', '~> 0.3.0'
30
30
  spec.add_runtime_dependency 'semantic', '~> 1.4'
31
- spec.add_runtime_dependency 'rainbow', '~> 2.1'
31
+ spec.add_runtime_dependency 'rainbow', '~> 2.2'
32
32
  spec.add_runtime_dependency 'highline', '~> 1.7'
33
33
  spec.add_runtime_dependency 'table_print', '~> 1.5'
34
34
  spec.add_runtime_dependency "git", '~> 1.3'
@@ -176,13 +176,13 @@ output :vpcid, Fn::ref(:vpc)
176
176
 
177
177
  Now that you have your template ready, you'll be able to use Cfer to create or update a CloudFormation stack:
178
178
 
179
- {% highlight bash %}
179
+ ```bash
180
180
  cfer converge vpc -t examples/vpc.rb --profile ${AWS_PROFILE} --region ${AWS_REGION}
181
181
  ```
182
182
 
183
183
  Which should produce something like this.
184
184
 
185
- ![Cfer Demo]({{ site.url }}/images/cfer/cfer-demo.gif)
185
+ ![Cfer Demo](https://raw.githubusercontent.com/seanedwards/cfer/master/doc/cfer-demo.gif)
186
186
 
187
187
  Use `cfer help` to get more usage information, or check `README.md` and `Rakefile` in the source repository to see how to embed Cfer into your own projects.
188
188
 
@@ -54,7 +54,8 @@ end
54
54
  # Other CloudFormation intrinsics, such as `Fn::Select` and `AWS::Region` are available as Ruby objects
55
55
  # Inspecting these functions will reveal that they simply return a Ruby hash representing the same CloudFormation structures
56
56
  availability_zone Fn::select(i, Fn::get_azs(AWS::region))
57
- cidr_block "172.42.#{i}.0/24"
57
+ # this calculates "172.42.#{i}.0/24"
58
+ cidr_block Fn::select(i, Fn::cidr(Fn::get_att(:vpc, :CidrBlock), 256, 8))
58
59
  vpc_id Fn::ref(:vpc)
59
60
  end
60
61
 
@@ -89,10 +89,9 @@ module Cfer
89
89
  stack_name: stack_name
90
90
  }
91
91
 
92
- rollback_opts[:role_arn] = options[:role_arn] if options[:role_arn]
93
-
94
92
  case operation
95
93
  when :created
94
+ rollback_opts[:role_arn] = options[:role_arn] if options[:role_arn]
96
95
  cfn_stack.delete_stack rollback_opts
97
96
  when :updated
98
97
  cfn_stack.cancel_update_stack rollback_opts
@@ -8,7 +8,7 @@ module Cfer::Cfn
8
8
  attr_reader :stack
9
9
 
10
10
  def initialize(options)
11
- super
11
+ super(options)
12
12
  @name = options[:stack_name]
13
13
  @options = options
14
14
  @options.delete :stack_name
@@ -72,7 +72,7 @@ module Cfer::Cfn
72
72
  current_version = Cfer::SEMANTIC_VERSION
73
73
  previous_version = fetch_cfer_version rescue nil
74
74
 
75
- current_hash = stack.git_version
75
+ current_hash = stack.git_state.sha rescue nil
76
76
  previous_hash = fetch_git_hash rescue nil
77
77
 
78
78
  # Compare current and previous versions and hashes?
@@ -112,15 +112,15 @@ module Cfer::Cfn
112
112
 
113
113
  Cfer::LOGGER.debug "==================="
114
114
 
115
- stack_options = {
116
- stack_name: name,
117
- capabilities: response.capabilities
118
- }
115
+ stack_options = options[:stack_options] || {}
116
+
117
+ stack_options.merge! stack_name: name, capabilities: response.capabilities
119
118
 
120
119
  stack_options[:on_failure] = options[:on_failure] if options[:on_failure]
121
120
  stack_options[:timeout_in_minutes] = options[:timeout] if options[:timeout]
122
121
  stack_options[:role_arn] = options[:role_arn] if options[:role_arn]
123
122
  stack_options[:notification_arns] = options[:notification_arns] if options[:notification_arns]
123
+ stack_options[:enable_termination_protection] = options[:enable_termination_protection] if options[:enable_termination_protection]
124
124
 
125
125
  stack_options.merge! parse_stack_policy(:stack_policy, options[:stack_policy])
126
126
 
@@ -4,6 +4,10 @@ module Cfer::Core::Functions
4
4
  {"Fn::Join" => [sep, [ *args ].flatten ]}
5
5
  end
6
6
 
7
+ def split(sep, str)
8
+ {"Fn::Split" => [sep, str ]}
9
+ end
10
+
7
11
  def ref(r)
8
12
  {"Ref" => r}
9
13
  end
@@ -40,10 +44,14 @@ module Cfer::Core::Functions
40
44
  {"Fn::Not" => [cond]}
41
45
  end
42
46
 
43
- def get_azs(region)
47
+ def get_azs(region = '')
44
48
  {"Fn::GetAZs" => region}
45
49
  end
46
50
 
51
+ def cidr(ip_block, count, size_mask)
52
+ {"Fn::Cidr" => [ip_block, count, size_mask]}
53
+ end
54
+
47
55
  def sub(str, vals = {})
48
56
  {"Fn::Sub" => [str, vals]}
49
57
  end
@@ -2,13 +2,15 @@ module Cfer::Core
2
2
  # Provides support for hooking into resource types, and evaluating code before or after properties are set
3
3
  module Hooks
4
4
  def pre_block
5
- self.class.pre_hooks.sort { |a, b| (a[:nice] || 0) <=> (b[:nice] || 0) }.each do |hook|
6
- Docile.dsl_eval(self, &hook[:block])
7
- end
5
+ eval_hooks self.class.pre_hooks
8
6
  end
9
7
 
10
8
  def post_block
11
- self.class.post_hooks.sort { |a, b| (a[:nice] || 0) <=> (b[:nice] || 0) }.each do |hook|
9
+ eval_hooks self.class.post_hooks
10
+ end
11
+
12
+ private def eval_hooks(hooks)
13
+ hooks.sort { |a, b| (a[:nice] || 0) <=> (b[:nice] || 0) }.each do |hook|
12
14
  Docile.dsl_eval(self, &hook[:block])
13
15
  end
14
16
  end
@@ -2,6 +2,21 @@ module Cfer::Core
2
2
  class Resource < Cfer::BlockHash
3
3
  include Cfer::Core::Hooks
4
4
 
5
+ class Handle
6
+ attr_reader :name
7
+ def initialize(name)
8
+ @name = name.to_s
9
+ end
10
+
11
+ def ref
12
+ Functions::Fn::ref(name)
13
+ end
14
+
15
+ def method_missing(method)
16
+ Functions::Fn::get_att(name, method.to_s.camelize)
17
+ end
18
+ end
19
+
5
20
  @@types = {}
6
21
 
7
22
  attr_reader :stack
@@ -16,6 +31,10 @@ module Cfer::Core
16
31
  build_from_block(&block)
17
32
  end
18
33
 
34
+ def handle
35
+ @handle ||= Handle.new(@name)
36
+ end
37
+
19
38
  # Sets a tag on this resource. The resource must support the CloudFormation `Tags` property.
20
39
  # @param k [String] The name of the tag to set
21
40
  # @param v [String] The value for this tag
@@ -13,7 +13,7 @@ module Cfer::Core
13
13
 
14
14
  attr_reader :options
15
15
 
16
- attr_reader :git_version
16
+ attr_reader :git_state
17
17
 
18
18
  def client
19
19
  @options[:client] || raise('No client set on this stack')
@@ -45,11 +45,16 @@ module Cfer::Core
45
45
  self[:Resources] = {}
46
46
  self[:Outputs] = {}
47
47
 
48
- if options[:client] && git = options[:client].git && @git_version = (git.object('HEAD^').sha rescue nil)
49
- self[:Metadata][:Cfer][:Git] = {
50
- Rev: @git_version,
51
- Clean: git.status.changed.empty?
52
- }
48
+ if options[:client] && git = options[:client].git
49
+ begin
50
+ @git_state = git.object('HEAD^')
51
+ self[:Metadata][:Cfer][:Git] = {
52
+ Rev: git_state.sha,
53
+ Clean: git.status.changed.empty?
54
+ }
55
+ rescue => e
56
+ Cfer::LOGGER.warn("Unable to add Git information to CloudFormation Metadata. #{e}")
57
+ end
53
58
  end
54
59
 
55
60
  @parameters = HashWithIndifferentAccess.new
@@ -140,7 +145,7 @@ module Cfer::Core
140
145
  rc = clazz.new(name, type, self, options, &block)
141
146
 
142
147
  self[:Resources][name] = rc
143
- rc
148
+ rc.handle
144
149
  end
145
150
 
146
151
  # Adds an output to the CloudFormation stack.
@@ -1,5 +1,5 @@
1
1
  module Cfer
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.0"
3
3
 
4
4
  begin
5
5
  require 'semantic'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Edwards
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-14 00:00:00.000000000 Z
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docile
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.2'
61
+ version: '2'
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
- version: '2.2'
68
+ version: '2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: aws-sdk-resources
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.2'
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
- version: '2.2'
82
+ version: '2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: preconditions
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.1'
117
+ version: '2.2'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.1'
124
+ version: '2.2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: highline
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  version: '0'
272
272
  requirements: []
273
273
  rubyforge_project:
274
- rubygems_version: 2.6.14
274
+ rubygems_version: 2.7.6.2
275
275
  signing_key:
276
276
  specification_version: 4
277
277
  summary: Toolkit for automating infrastructure using AWS CloudFormation