stack_master 2.11.0 → 2.12.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: 44b54b0c2a5d9050de40c5eb89ec056d423e7e4403071aa295d3165c7eb08128
4
- data.tar.gz: 6da32d39a8cb7c1b7f3448516c2fab14fbdb41247a708ebb3bffc59d10111fa4
3
+ metadata.gz: 02eda4742884cf2aa48568ad0e330b375f7548f12f3077be3167bd782a51868d
4
+ data.tar.gz: 6f3159eb1b681bda06e4c128d4746f05484a75f91c1a2119d9c02523f912b48f
5
5
  SHA512:
6
- metadata.gz: 10eab8adaca08fb72e5751ade8a554b6892f95553a9581c87fba01f2967fde18fae5111e2b97243af83673ba9b2578ea0541ee0b4e70882cae3c2d5a483c0630
7
- data.tar.gz: 7542bd369cd86fdbf5c3a198fb8bf331db3acefbc1271850f4603a67ba1ac5eed69d4c1d056ccba60e644e852ec04460129f48697dfb9df545a9a5a7a2b0221e
6
+ metadata.gz: 4670acd897af5bd58083f65187c23c7e7add969ca1d906899ce18065bcc24287d78854bd67baa82a1225dab4277b3392fa03cc3a5ffe49c13cffd3665ca2ea99
7
+ data.tar.gz: 8ea47d21747c13e9685f0f5cacbb12663c28df649823981c5e1a94e982bc7798bd2b93828be921e7e2e4267e3c3aa3d1f246aeb8f99f0eb91d34d2ce24594263
data/README.md CHANGED
@@ -143,7 +143,8 @@ stacks:
143
143
  ## Templates
144
144
 
145
145
  StackMaster supports CloudFormation templates in plain JSON or YAML. Any `.yml` or `.yaml` file will be processed as
146
- YAML, while any `.json` file will be processed as JSON.
146
+ YAML, while any `.json` file will be processed as JSON. Additionally, YAML files can be pre-processed using ERB and
147
+ compile-time parameters.
147
148
 
148
149
  ### Ruby DSLs
149
150
  By default, any template ending with `.rb` will be processed as a [SparkleFormation](https://github.com/sparkleformation/sparkle_formation)
@@ -199,12 +200,13 @@ stacks:
199
200
 
200
201
  ### Compile Time Parameters
201
202
 
202
- Compile time parameters can be used for [SparkleFormation](http://www.sparkleformation.io) templates. It conforms and
203
- allows you to use the [Compile Time Parameters](http://www.sparkleformation.io/docs/sparkle_formation/compile-time-parameters.html) feature.
203
+ Compile time parameters can be defined in a stack's parameters file, using the key `compile_time_parameters`. Keys in
204
+ parameter files are automatically converted to camel case.
204
205
 
205
- A simple example looks like this
206
+ As an example:
206
207
 
207
208
  ```yaml
209
+ # parameters/some_stack.yml
208
210
  vpc_cidr: 10.0.0.0/16
209
211
  compile_time_parameters:
210
212
  subnet_cidrs:
@@ -212,7 +214,37 @@ compile_time_parameters:
212
214
  - 10.0.2.0/28
213
215
  ```
214
216
 
215
- Keys in parameter files are automatically converted to camel case.
217
+ #### SparkleFormation
218
+
219
+ Compile time parameters can be used for [SparkleFormation](http://www.sparkleformation.io) templates. It conforms and
220
+ allows you to use the [Compile Time Parameters](http://www.sparkleformation.io/docs/sparkle_formation/compile-time-parameters.html) feature.
221
+
222
+ #### CloudFormation YAML ERB
223
+
224
+ Compile time parameters can be used to pre-process YAML CloudFormation templates. An example template:
225
+
226
+ ```yaml
227
+ # templates/some_stack_template.yml.erb
228
+ Parameters:
229
+ VpcCidr:
230
+ Type: String
231
+ Resources:
232
+ Vpc:
233
+ Type: AWS::EC2::VPC
234
+ Properties:
235
+ CidrBlock: !Ref VpcCidr
236
+ # Given the two subnet_cidrs parameters, this creates two resources:
237
+ # SubnetPrivate0 with a CidrBlock of 10.0.0.0/28, and
238
+ # SubnetPrivate1 with a CidrBlock of 10.0.2.0/28
239
+ <% params["SubnetCidrs"].each_with_index do |cidr, index| %>
240
+ SubnetPrivate<%= index %>:
241
+ Type: AWS::EC2::Subnet
242
+ Properties:
243
+ VpcId: !Ref Vpc
244
+ AvailabilityZone: ap-southeast-2
245
+ CidrBlock: <%= cidr %>
246
+ <% end %>
247
+ ```
216
248
 
217
249
  ## Parameter Resolvers
218
250
 
@@ -52,6 +52,7 @@ module StackMaster
52
52
  require 'stack_master/template_compilers/sparkle_formation'
53
53
  require 'stack_master/template_compilers/json'
54
54
  require 'stack_master/template_compilers/yaml'
55
+ require 'stack_master/template_compilers/yaml_erb'
55
56
  require 'stack_master/template_compilers/cfndsl'
56
57
 
57
58
  module Commands
@@ -92,6 +92,7 @@ module StackMaster
92
92
  json: :json,
93
93
  yml: :yaml,
94
94
  yaml: :yaml,
95
+ erb: :yaml_erb,
95
96
  }
96
97
  end
97
98
 
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StackMaster::TemplateCompilers
4
+ class YamlErb
5
+ def self.require_dependencies
6
+ require 'erubis'
7
+ require 'yaml'
8
+ end
9
+
10
+ def self.compile(template_dir, template, compile_time_parameters, _compiler_options = {})
11
+ template_file_path = File.join(template_dir, template)
12
+ template = Erubis::Eruby.new(File.read(template_file_path))
13
+ template.filename = template_file_path
14
+
15
+ template.result(params: compile_time_parameters)
16
+ end
17
+
18
+ StackMaster::TemplateCompiler.register(:yaml_erb, self)
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module StackMaster
2
- VERSION = "2.11.0"
2
+ VERSION = "2.12.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Hodgkiss
8
8
  - Glen Stampoultzis
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-02 00:00:00.000000000 Z
12
+ date: 2020-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -539,6 +539,7 @@ files:
539
539
  - lib/stack_master/template_compilers/json.rb
540
540
  - lib/stack_master/template_compilers/sparkle_formation.rb
541
541
  - lib/stack_master/template_compilers/yaml.rb
542
+ - lib/stack_master/template_compilers/yaml_erb.rb
542
543
  - lib/stack_master/template_utils.rb
543
544
  - lib/stack_master/test_driver/cloud_formation.rb
544
545
  - lib/stack_master/test_driver/s3.rb
@@ -556,9 +557,9 @@ licenses:
556
557
  metadata:
557
558
  bug_tracker_uri: https://github.com/envato/stack_master/issues
558
559
  changelog_uri: https://github.com/envato/stack_master/blob/master/CHANGELOG.md
559
- documentation_uri: https://www.rubydoc.info/gems/stack_master/2.11.0
560
- source_code_uri: https://github.com/envato/stack_master/tree/v2.11.0
561
- post_install_message:
560
+ documentation_uri: https://www.rubydoc.info/gems/stack_master/2.12.0
561
+ source_code_uri: https://github.com/envato/stack_master/tree/v2.12.0
562
+ post_install_message:
562
563
  rdoc_options: []
563
564
  require_paths:
564
565
  - lib
@@ -573,8 +574,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
573
574
  - !ruby/object:Gem::Version
574
575
  version: '0'
575
576
  requirements: []
576
- rubygems_version: 3.0.4
577
- signing_key:
577
+ rubygems_version: 3.1.2
578
+ signing_key:
578
579
  specification_version: 4
579
580
  summary: StackMaster is a sure-footed way of creating, updating and keeping track
580
581
  of Amazon (AWS) CloudFormation stacks.