cfhighlander 0.2.1.alpha.43 → 0.2.1

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: b0076c7a6d8d8d5dcfe21a9c57601f659014cc64dadfc78c890b78ac98aaee7e
4
- data.tar.gz: d9688f728ef4edd875f8603b8733c153a95270a1650b0555a706cf9d0f7f5a6b
3
+ metadata.gz: 2db06592f56122df80f8ad27fb1bc67f8920b47a623dbd8f6343f265998efa60
4
+ data.tar.gz: fcf86ec795983ec1a73d565e49685314b88dd0bc2cc22174fa1bb41841dfbaa2
5
5
  SHA512:
6
- metadata.gz: 928880bc75f3bc9665ab84c7bbd8d50fe8e310d520365e065c1c036cbdc8c67195e37059e608e4340dd018943965f322361287a057a3450771905997648960ad
7
- data.tar.gz: 7ba9c66b2e655044c62c7b6db12d42451e46e5c5239206b879b1951a69472c1fe883b491efbfdcd26fb38a850663abcf7e673150bdf61ec5e5ed85d383c3c490
6
+ metadata.gz: 6a138171e3a15cee57f1ac71a55f8c5bce7d1db15560fe5ee4c11810c0e496e81e838350754375b377f9ffca562fb75abe5b897e1a3ae4ae36af7f5ec518ecea
7
+ data.tar.gz: 8a2c7a47987d4500a074346835c65093b3e1dbbdcfbb1d7800ea3fe7d749c3ba0c3fb6e95d0fd4d89b8fe5b530d00fc9f6f57ded2b0fe863ff721319bd51f623
data/README.md CHANGED
@@ -1,27 +1,24 @@
1
1
  [![Build Status](https://travis-ci.com/theonestack/cfhighlander.svg?branch=develop)](https://travis-ci.com/theonestack/cfhighlander)
2
2
 
3
- # Cfhighlander
3
+ # Highlander
4
4
 
5
- Cfhighlander is DSL processor that enables composition and orchestration of Amazon CloudFormation templates
5
+ Highlander is DSL processor that enables composition and orchestration of Amazon CloudFormation templates
6
6
  written using [CfnDsl](https://github.com/cfndsl/cfndsl) in an abstract way. It tries to tackle problem of merging multiple templates into master
7
7
  template in an elegant way, so higher degree of template reuse can be achieved. It does so by formalising commonly
8
- used cfndsl template composition patterns via DSL statements. For an example, passing output of one stack into other stack is done
9
- automatically if parameter and output names are the same,
10
- rather than wiring them manually in 'master' cfndsl template. For this example to
8
+ used patterns via DSL statements. For an example, passing output of one stack into other stack is achieved using
9
+ `OutputParam` highlander DSL statement, rather than wiring this parameters manually in cfndsl templates. For this example to
11
10
  work, parent component will have to pull in both component rendering output values, and component pulling them in
12
- as parameters. Cfhighlander allows for greater reuse of component templates by allowing references to templates
13
- via git urls, and s3 urls. [Theonestack](https://github.com/theonestack) has several prebuilt component templates to use,
14
- with repositories from this org being one of the default sources for searching component templates.
11
+ as parameters. It also enables it's user to build component library, where components can be distributed to s3, and
12
+ consequentially references to them resolved.
15
13
 
16
- Highlander DSL produces CloudFormation templates in 4 phases
14
+ Highlander DSL produces CloudFormation templates in 3 phases
17
15
 
18
16
  - Processing referenced component's configuration and resolving configuration exports
19
- - Wiring parameters from components to their inner components
20
17
  - Producing [CfnDsl](https://github.com/cfndsl/cfndsl) templates for all components and subcomponents as intermediary
21
18
  step
22
19
  - Producing resulting CloudFormation templates using configuration and templates generated in two previous phases.
23
20
 
24
- Each phase (aside from parameter wiring) above is executable as stand-alone through CLI, making development of Highlander templates easier by enabling
21
+ Each phase above is executable as stand-alone through CLI, making development of Highlander templates easier by enabling
25
22
  debugging of produced configuration and cfndsl templates.
26
23
 
27
24
 
@@ -51,7 +48,7 @@ this file defines map used within component itself
51
48
  - Define cfndsl template used for building CloudFormation resources
52
49
 
53
50
 
54
- **Outer component** is component that defines other component via cfhighlander dsl `Component` statement. Defined component
51
+ **Outer component** is component that defines other component via higlander dsl `Component` statement. Defined component
55
52
  is called **inner component**. Components defined under same outer component are **sibling components**
56
53
 
57
54
  ## Usage
@@ -61,30 +58,30 @@ For both ways, highlander is distributed as ruby gem
61
58
 
62
59
 
63
60
  ```bash
64
- $ gem install cfhighlander
65
- $ cfhighlander help
66
- cfhighlander commands:
67
- cfhighlander cfcompile component[@version] -f, --format=FORMAT # Compile Highlander component to CloudFormation templates
68
- cfhighlander cfpublish component[@version] -f, --format=FORMAT # Publish CloudFormation template for component, and it' referenced subcomponents
69
- cfhighlander configcompile component[@version] # Compile Highlander components configuration
70
- cfhighlander dslcompile component[@version] -f, --format=FORMAT # Compile Highlander component configuration and create cfndsl templates
71
- cfhighlander help [COMMAND] # Describe available commands or one specific command
72
- cfhighlander publish component[@version] [-v published_version] # Publish CloudFormation template for component, and it' referenced subcomponents
61
+ $ gem install highlander
62
+ $ highlander help
63
+ highlander commands:
64
+ highlander cfcompile component[@version] -f, --format=FORMAT # Compile Highlander component to CloudFormation templates
65
+ highlander cfpublish component[@version] -f, --format=FORMAT # Publish CloudFormation template for component, and it' referenced subcomponents
66
+ highlander configcompile component[@version] # Compile Highlander components configuration
67
+ highlander dslcompile component[@version] -f, --format=FORMAT # Compile Highlander component configuration and create cfndsl templates
68
+ highlander help [COMMAND] # Describe available commands or one specific command
69
+ highlander publish component[@version] [-v published_version] # Publish CloudFormation template for component, and it' referenced subcomponents
73
70
 
74
71
  ```
75
72
  ### Working directory
76
73
 
77
74
  All templates and configuration generated are placed in `$WORKDIR/out` directory. Optionally, you can alter working directory
78
- via `CFHIGHLANDER_WORKDIR` environment variable.
75
+ via `HIGHLANDER_WORKDIR` environment variable.
79
76
 
80
77
  ### Commands
81
78
 
82
79
  To get full list of options for any of cli commands use `highlander help command_name` syntax
83
80
 
84
81
  ```bash
85
- $ cfhighlander help publish
82
+ $ highlander help publish
86
83
  Usage:
87
- cfhighlander publish component[@version] [-v published_version]
84
+ highlander publish component[@version] [-v published_version]
88
85
 
89
86
  Options:
90
87
  [--dstbucket=DSTBUCKET] # Distribution S3 bucket
@@ -98,7 +95,7 @@ Publish CloudFormation template for component,
98
95
 
99
96
  #### Silent mode
100
97
 
101
- Cfhighlander DSL processor has built-in support for packaging and deploying AWS Lambda functions. Some of these lambda
98
+ Highlander DSL processor has built-in support for packaging and deploying AWS Lambda functions. Some of these lambda
102
99
  functions may require shell command to be executed (e.g. pulling library dependencies) prior their packaging in ZIP archive format.
103
100
  Such commands are potential security risk, as they allow execution of arbitrary code, so for this reason user agreement is required
104
101
  e.g:
@@ -139,11 +136,11 @@ cfndsl templates. Check component configuration section for more details.
139
136
 
140
137
  #### dslcompile
141
138
 
142
- *dslcompile* will produce intermediary cfndsl templates. This is useful for debugging cfhighlander components
139
+ *dslcompile* will produce intermediary cfndsl templates. This is useful for debugging highlander components
143
140
 
144
141
  #### publish
145
142
 
146
- *publish* command publishes cfhighlander components source code to s3 location (compared to *cfpublish* which is publishing
143
+ *publish* command publishes highlander components source code to s3 location (compared to *cfpublish* which is publishing
147
144
  compiled cloudformation templates). Same CLI / DSL options apply as for *cfpublish* command. Version defaults to `latest`
148
145
 
149
146
 
@@ -172,7 +169,7 @@ This configuration level overrides component's own config file.
172
169
  - Outer component explicit configuration. You can pass `config` named parameter to `Component` statement, such as
173
170
 
174
171
  ```ruby
175
- CfhighlanderTemplate do
172
+ HighlanderComponent do
176
173
 
177
174
  # ...
178
175
  # some dsl code
@@ -260,7 +257,7 @@ Parameters block is used to define CloudFormation template parameters, and metad
260
257
  are wired with outer or sibling components.
261
258
 
262
259
  ```ruby
263
- CfhighlanderTemplate do
260
+ HighlanderComponent do
264
261
  Parameters do
265
262
  ##
266
263
  ## parameter definitions here
@@ -273,117 +270,81 @@ Parameter block supports following parameters
273
270
 
274
271
  #### ComponentParam
275
272
 
276
- `ComponentParam` - Component parameter exposes parameter to be wired from outer component. Cfhighlander's
277
- autowiring mechanism will try and find any stack outputs from other components defined by outer components with name
278
- matching. If there is no explicit value provided, or autowired from outputs, parameter will be propagated to outer component.
279
-
280
- Propagated parameter will be prefixed with component name **if it is not defined as global parameter**. Otherwise,
281
- parameter name is kept in full.
282
-
283
- Example below demonstrates 3 different ways of providing parameter values from outer to inner component.
284
-
285
- - Provide value explicitly
286
- - Provide value explicitly as output of another component
287
- - Autowire value from output of another component with the same name
288
- - Propagate parameter to outer component
273
+ `ComponentParam` - Component parameter takes name and default value. It defines component parameter
274
+ that is not auto-wired in any way with outer component. This parameter will either use default value, or value
275
+ explicitly passed from outer component.
289
276
 
290
277
  ```ruby
291
278
 
292
- # Inner Component 1
293
- CfhighlanderTemplate do
279
+ # Inner Component
280
+ HighlanderComponent do
294
281
  Name 's3'
295
282
  Parameters do
296
283
  ComponentParam 'BucketName','highlander.example.com.au'
297
- ComponentParam 'BucketName2',''
298
- ComponentParam 'BucketName3',''
299
- ComponentParam 'BucketName4','', isGlobal: false # default value is false
300
- ComponentParam 'BucketName5','', isGlobal: true
301
284
  end
302
-
303
285
  end
304
-
305
286
  ```
306
287
 
307
288
  ```ruby
308
- # Inner Component 2
309
- CfhighlanderTemplate do
310
- Name 'nameproducer'
311
-
312
- # has output 'bucket name defined in cfdnsl
289
+ # Outer component
290
+ HighlanderComponent do
291
+ # instantiate inner component with name and template
292
+ Component template:'s3',
293
+ name:'s3',
294
+ parameters:{'BucketName' => 'outer.example.com.au'}
313
295
  end
296
+ ```
314
297
 
298
+ #### StackParam
315
299
 
316
- # -- contents of cfndsl
317
- CloudFormation do
300
+ `StackParam` - Stack parameter bubbles up to it's outer component. Outer component will either define top level parameter
301
+ with same name as inner component parameter (if parameter is defined as global), or it will be prefixed with inner component name.
318
302
 
319
- Condition 'AlwaysFalse', FnEquals('true','false')
320
- S3_Bucket :resourcetovalidateproperly do
321
- Condition 'AlwaysFalse'
322
- end
323
303
 
324
- Output('BucketName') do
325
- Value('highlanderbucketautowired.example.com.au')
326
- end
304
+ ```ruby
305
+ # Outer component
306
+ HighlanderComponent do
307
+ Component template:'s3',name:'s3'
327
308
  end
328
-
329
-
330
309
  ```
331
310
 
332
311
  ```ruby
333
- # Outer component
334
- CfhighlanderTemplate do
335
- Component 'nameproducer'
336
- Component 's3' do
337
- parameter name: 'BucketName2', value: 'nameproducer.BucketName'
338
- parameter name: 'BucketName3', value: 'mybucket.example.cfhighlander.org'
339
- end
312
+ # Inner component
313
+ HighlanderComponent do
314
+ Name 's3'
315
+ Parameters do
316
+ StackParam 'EnvironmentName','dev', isGlobal:true
317
+ StackParam 'BucketName','highlander.example.com.au', isGlobal:false
318
+ end
340
319
  end
341
-
342
320
  ```
343
321
 
344
322
 
345
- Example above translates to following wiring of parameters in cfndsl template
323
+ Example above translates to following cfndsl template in outer component
346
324
  ```ruby
347
325
  CloudFormation do
348
326
 
349
- # Parameter that was propagated
350
- Parameter('s3BucketName4') do
351
- Type 'String'
352
- Default ''
353
- NoEcho false
354
- end
355
-
356
- Parameter('BucketName5') do
357
- Type 'String'
358
- Default ''
359
- NoEcho false
327
+ Parameter('EnvironmentName') do
328
+ Type 'String'
329
+ Default ''
360
330
  end
361
331
 
362
- CloudFormation_Stack('s3') do
363
- TemplateURL './s3.compiled.yaml'
364
- Parameters ({
365
-
366
- # Paramater that was auto-wired
367
- 'BucketName' => {"Fn::GetAtt":["nameproducer","Outputs.BucketName"]},
368
-
369
- # Parameter that was explicitly wired as output param from another component
370
- 'BucketName2' => {"Fn::GetAtt":["nameproducer","Outputs.BucketName"]},
371
-
372
- # Paramater that was explicitly provided
373
- 'BucketName3' => 'mybucket.example.cfhighlander.org',
374
-
375
- # Reference to parameter that was propagated. isGlobal: false when defining
376
- # parameter, so parameter name is prefixed with component name
377
- 'BucketName4' => {"Ref":"s3BucketName4"},
378
-
379
- # Reference to parameter that was propagated. isGlobal: true when defining
380
- # parameter, so parameter name is not prefixed, but rather propagated as-is
381
- 'BucketName5' => {"Ref":"BucketName5"},
382
-
383
- })
384
- end
332
+ Parameter('s3BucketName') do
333
+ Type 'String'
334
+ Default 'highlander.example.com.au'
335
+ end
336
+
337
+ CloudFormation_Stack('s3') do
338
+ TemplateURL 'https://distributionbucket/dist/latest/s3.yaml'
339
+ Parameters ({
340
+
341
+ 'EnvironmentName' => Ref('EnvironmentName'),
342
+
343
+ 'BucketName' => Ref('s3BucketName'),
344
+
345
+ })
346
+ end
385
347
  end
386
-
387
348
  ```
388
349
 
389
350
 
@@ -397,7 +358,7 @@ This DSL statements takes a full body, as Mapping name, Map key, and value key n
397
358
 
398
359
  ```ruby
399
360
  # Inner component
400
- CfhighlanderTemplate do
361
+ HighlanderComponent do
401
362
  Name 's3'
402
363
  Parameters do
403
364
  MappingParam 'BucketName' do
@@ -409,13 +370,17 @@ end
409
370
  ```
410
371
 
411
372
 
373
+ #### OutputParam
374
+
375
+ TBD
376
+
412
377
  ### DependsOn
413
378
 
414
379
  `DependsOn` - this will include any globally exported libraries from given
415
380
  template. E.g.
416
381
 
417
382
  ```ruby
418
- CfhighlanderTemplate do
383
+ HighlanderComponent do
419
384
  Name 's3'
420
385
  DependsOn 'vpc@1.0.3'
421
386
  end
@@ -433,46 +398,7 @@ so extension methods can be consumed within cfndsl template.
433
398
  #### Referencing
434
399
 
435
400
 
436
- ## Finding templates and creating components
437
-
438
-
439
- Templates are located by default in following locations
440
-
441
- - `$WD`
442
- - `$WD/$componentname`
443
- - `$WD/components/$componentname`
444
- - `~/.cfhighlander/components/componentname/componentversion`
445
- - `https://github.com/cfhighlander/theonestack/hl-component-$componentname` on `master` branch
446
-
447
- Location of component templates can be given as git/github repo:
448
-
449
- ```ruby
450
-
451
- CfhighlanderTemplate do
452
-
453
- # pulls directly from master branch of https://github.com/theonestack/hl-component-vpc
454
- Component name: 'vpc0', template: 'vpc'
455
-
456
- # specify branch github.com: or github: work. You specify branch with hash
457
- Component name: 'vpc1', template: 'github:theonestack/hl-component-vpc#master'
458
-
459
- # you can use git over ssh
460
- # Component name: 'vpc2', template: 'git:git@github.com:theonestack/hl-component-vpc.git'
461
-
462
- # use git over https
463
- Component name: 'vpc3', template: 'git:https://github.com/theonestack/hl-component-sns.git'
464
-
465
- # specify .snapshot to always clone fresh copy
466
- Component name: 'vpc4', template: 'git:https://github.com/theonestack/hl-component-sns.git#master.snapshot'
467
-
468
- # by default, if not found locally, highlander will search for https://github.com/theonestack/component-$componentname
469
- # in v${version} branch (or tag for that matter)
470
- Component name: 'vpc5', template: 'vpc@1.0.4'
471
-
472
- end
473
-
474
- ```
475
-
401
+ ## Finding and loading components
476
402
 
477
403
  ## Rendering CloudFormation templates
478
404
 
@@ -482,4 +408,4 @@ end
482
408
 
483
409
  Any extensions placed within `cfndsl_ext` folder will be
484
410
  available in cfndsl templates of all components. Any extensions placed within `hl_ext` folder are
485
- available in cfhighlander templates of all components.
411
+ available in highlander templates of all components.
data/bin/cfhighlander CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative('./cfhighlander')
3
+ require_relative('./highlander')
@@ -9,10 +9,10 @@
9
9
 
10
10
  require 'thor'
11
11
  require 'rubygems'
12
- require_relative '../lib/cfhighlander.compiler'
13
- require_relative '../lib/cfhighlander.factory'
14
- require_relative '../lib/cfhighlander.publisher'
15
- require_relative '../lib/cfhighlander.validator'
12
+ require_relative '../lib//highlander.compiler'
13
+ require_relative '../lib/highlander.factory'
14
+ require_relative '../lib/highlander.publisher'
15
+ require_relative '../lib/highlander.validator'
16
16
 
17
17
  class HighlanderCli < Thor
18
18
 
@@ -22,15 +22,15 @@ class HighlanderCli < Thor
22
22
 
23
23
  desc 'configcompile component[@version]', 'Compile Highlander components configuration'
24
24
 
25
- def configcompile(template_name)
25
+ def configcompile(component_name)
26
26
 
27
27
  # find and load component
28
- component_loader = Cfhighlander::Factory::ComponentFactory.new
29
- component = component_loader.loadComponentFromTemplate(template_name)
28
+ component_loader = Highlander::Factory::ComponentFactory.new
29
+ component = component_loader.findComponent(component_name)
30
30
  component.load
31
31
 
32
32
  # compile cfndsl template
33
- component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(component)
33
+ component_compiler = Highlander::Compiler::ComponentCompiler.new(component)
34
34
  component_compiler.writeConfig(true)
35
35
  end
36
36
 
@@ -50,7 +50,7 @@ class HighlanderCli < Thor
50
50
  component = build_component(options, component_name)
51
51
 
52
52
  # compile cfndsl template
53
- component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(component)
53
+ component_compiler = Highlander::Compiler::ComponentCompiler.new(component)
54
54
  component_compiler.silent_mode = options[:quiet]
55
55
  out_format = options[:format]
56
56
  component_compiler.compileCfnDsl out_format
@@ -75,12 +75,12 @@ class HighlanderCli < Thor
75
75
  component = build_component(options, component_name)
76
76
 
77
77
  # compile cloud formation
78
- component_compiler = Cfhighlander::Compiler::ComponentCompiler.new(component)
78
+ component_compiler = Highlander::Compiler::ComponentCompiler.new(component)
79
79
  component_compiler.silent_mode = options[:quiet]
80
80
  out_format = options[:format]
81
81
  component_compiler.compileCloudFormation out_format
82
82
  if options[:validate]
83
- component_validator = Cfhighlander::Cloudformation::Validator.new(component)
83
+ component_validator = Highlander::Cloudformation::Validator.new(component)
84
84
  component_validator.validate(component_compiler.cfn_template_paths, out_format)
85
85
  end
86
86
  component_compiler
@@ -103,7 +103,7 @@ class HighlanderCli < Thor
103
103
 
104
104
  def cfpublish(component_name)
105
105
  compiler = cfcompile(component_name)
106
- publisher = Cfhighlander::Publisher::ComponentPublisher.new(compiler.component, false)
106
+ publisher = Highlander::Publisher::Component.new(compiler.component, false)
107
107
  publisher.publishFiles(compiler.cfn_template_paths + compiler.lambda_src_paths)
108
108
  end
109
109
 
@@ -117,35 +117,37 @@ class HighlanderCli < Thor
117
117
  method_option :version, :type => :string, :required => false, :default => nil, :aliases => '-v',
118
118
  :desc => 'Distribution component version, defaults to latest'
119
119
 
120
- def publish(template_name)
120
+ def publish(component_name)
121
121
  component_version = options[:version]
122
122
  distribution_bucket = options[:dstbucket]
123
123
  distribution_prefix = options[:dstprefix]
124
124
 
125
125
  # find and load component
126
- component_loader = Cfhighlander::Factory::ComponentFactory.new
127
- component = component_loader.loadComponentFromTemplate(template_name)
126
+ component_loader = Highlander::Factory::ComponentFactory.new
127
+ component = component_loader.findComponent(component_name)
128
128
  component.version = component_version
129
129
  component.distribution_bucket = distribution_bucket unless distribution_bucket.nil?
130
130
  component.distribution_prefix = distribution_prefix unless distribution_prefix.nil?
131
131
  component.load
132
132
 
133
- publisher = Cfhighlander::Publisher::ComponentPublisher.new(component, true)
133
+ publisher = Highlander::Publisher::Component.new(component, true)
134
134
  publisher.publishComponent
135
135
  end
136
136
 
137
137
  end
138
138
 
139
139
  # build component from passed cli options
140
- def build_component(options, template_name)
141
-
140
+ def build_component(options, component_name)
141
+ if ENV['HIGHLANDER_WORKDIR'].nil?
142
+ ENV['HIGHLANDER_WORKDIR'] = Dir.pwd
143
+ end
142
144
  component_version = options[:version]
143
145
  distribution_bucket = options[:dstbucket]
144
146
  distribution_prefix = options[:dstprefix]
145
147
 
146
148
  # find and load component
147
- component_loader = Cfhighlander::Factory::ComponentFactory.new
148
- component = component_loader.loadComponentFromTemplate(template_name)
149
+ component_loader = Highlander::Factory::ComponentFactory.new
150
+ component = component_loader.findComponent(component_name)
149
151
  component.version = component_version unless component_version.nil?
150
152
  component.distribution_bucket = distribution_bucket unless distribution_bucket.nil?
151
153
  component.distribution_prefix = distribution_prefix unless distribution_prefix.nil?
@@ -153,11 +155,4 @@ def build_component(options, template_name)
153
155
  component
154
156
  end
155
157
 
156
- if ENV['CFHIGHLANDER_WORKDIR'].nil?
157
- ENV['CFHIGHLANDER_WORKDIR'] = Dir.pwd
158
- end
159
- if ENV['HIGHLANDER_WORKDIR'].nil?
160
- ENV['HIGHLANDER_WORKDIR'] = Dir.pwd
161
- end
162
-
163
158
  HighlanderCli.start