cfhighlander 0.12.4 → 0.12.7

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: 604f8f52d76f55b9bd84c22054f03298c4fe27a462843d4a24799bf2913ecf71
4
- data.tar.gz: d5934fff23883b7f1726db24de1d62dc501d86e03e1748410bcb277881a27244
3
+ metadata.gz: d2dfe3eb66664ba5c592e060c0c2257f890fa8ed03f7583d396857a8d1b789cd
4
+ data.tar.gz: 0577fcd3991f9e5fbb4b146c705c791a678523c04a025203255375ab1b264e98
5
5
  SHA512:
6
- metadata.gz: 78787af0a8c18c824e9af82c29c1db585965246a8175438ff9f50242999bbe3ace19694f6c8f03995d87d62a414569263db06dac9b52ee5da8460afd817ebf22
7
- data.tar.gz: be064150b8f28d1d13e79593ce8e5a268c1c7ea87a602906c2592c8fd1005097e63f3f48e4f0e0823c3c4879cfbaf33f1f34f9901babb70a418c148e7aa98985
6
+ metadata.gz: ea89979f91b1a001a87c0779b57d7e6efad18a1897b0bc4ca8bcf69c0132694a4131c2d312d1451aa8cc0a8cd0cafa6abb44458097f69650e84a7ecd7026eae9
7
+ data.tar.gz: e7ab34cb43ad010ad12ae0dd4193c0cf247d24878bd07f2a4701d07d0fed419bc573c7ba649350b0d2e264a23864c63d9427fefa80184abdf915600ac85dcc5d
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/theonestack/cfhighlander.svg?branch=develop)](https://travis-ci.org/theonestack/cfhighlander) [![Join the chat at https://gitter.im/theonestack/cfhighlander](https://badges.gitter.im/theonestack/cfhighlander.svg)](https://gitter.im/theonestack/cfhighlander?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1
+ ![Build Status](https://github.com/theonestack/cfhighlander/actions/workflows/build-gem.yml/badge.svg) [![Join the chat at https://gitter.im/theonestack/cfhighlander](https://badges.gitter.im/theonestack/cfhighlander.svg)](https://gitter.im/theonestack/cfhighlander?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
2
 
3
3
  # Intro
4
4
 
@@ -863,6 +863,27 @@ end
863
863
 
864
864
  ```
865
865
 
866
+ ### Publishing Additonal Artifacts
867
+
868
+ If you need to publish additonal files along with your cloudformation templates you can use the following DSL:
869
+
870
+ ```ruby
871
+ CfhighlanderTemplate do
872
+ Name 'my_app'
873
+ PublishArtifact file: "my-apigateway-spec.yaml"
874
+ end
875
+ ```
876
+
877
+ This will upload the file `my-apigateway-spec.yaml` to the s3 destnation/distribution bucket using the default s3 prefix. If you want to override the s3 key you can use
878
+
879
+ ```ruby
880
+ CfhighlanderTemplate do
881
+ Name 'my_app'
882
+ PublishArtifact file: "my-apigateway-spec.yaml", key: '/my-custom-path/my-custom-file.yaml'
883
+ end
884
+ ```
885
+
886
+
866
887
  ## Finding templates and creating components
867
888
 
868
889
 
@@ -1038,3 +1059,4 @@ Test Highlander component with test case config
1038
1059
  ### Reports
1039
1060
 
1040
1061
  By default test will print the output to stdout. You can output to a file with a format of xml or json using the `-r` option
1062
+
@@ -30,6 +30,7 @@ def render_lambda_functions(cfndsl, lambdas, lambda_metadata, distribution)
30
30
  S3Bucket: distribution['bucket'],
31
31
  S3Key: "#{distribution['prefix']}/#{distribution['version']}/#{lambda_metadata['path'][key]}"
32
32
  })
33
+ Layers lambda_config['layers'] unless lambda_config['layers'].nil?
33
34
 
34
35
  Environment(Variables: Hash[environment.collect { |k, v| [k, v] }])
35
36
 
@@ -155,7 +155,7 @@ module Cfhighlander
155
155
  param_ovr[:minLength] = minLength unless minLength.nil?
156
156
  param_ovr[:minValue] = minValue unless minValue.nil?
157
157
  @component_loaded.highlander_dsl.Parameters do
158
- ComponentParam name, value, param_ovr
158
+ ComponentParam name, value, **param_ovr
159
159
  end
160
160
  else
161
161
  parameter.default_value = defaultValue unless defaultValue.nil?
@@ -37,7 +37,8 @@ module Cfhighlander
37
37
  :lambda_functions_keys,
38
38
  :description,
39
39
  :dependson_components,
40
- :template_dir
40
+ :template_dir,
41
+ :publish_artifacts
41
42
 
42
43
  attr_reader :conditions,
43
44
  :subcomponents,
@@ -63,6 +64,7 @@ module Cfhighlander
63
64
  # execution blocks for subcomponents
64
65
  @subcomponents_exec = {}
65
66
  @template_dir = nil
67
+ @publish_artifacts = []
66
68
  end
67
69
 
68
70
  # DSL statements
@@ -207,6 +209,11 @@ module Cfhighlander
207
209
  @lambda_functions_keys << config_key
208
210
  end
209
211
 
212
+ def PublishArtifact(file: nil, key: key=nil)
213
+ puts "INFO: adding artifact #{file} to publishing list"
214
+ @publish_artifacts << {file: file, key: key}
215
+ end
216
+
210
217
  # Internal and interface functions
211
218
 
212
219
  def loadComponents
@@ -467,11 +474,11 @@ def CfhighlanderTemplate(&block)
467
474
 
468
475
  if @parent_dsl.nil?
469
476
  instance = Cfhighlander::Dsl::HighlanderTemplate.new
470
- puts "Processing higlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
477
+ puts "Processing highlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
471
478
  "\n\tConfig:#{@config}"
472
479
  else
473
480
  instance = @parent_dsl
474
- puts "Processing higlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
481
+ puts "Processing highlander component #{@name}\n\tLocation:#{@highlander_dsl_path}" +
475
482
  "\n\tConfig:#{@config}\n\tParent: #{@parent_template}"
476
483
  end
477
484
 
@@ -0,0 +1,3 @@
1
+ module Cfhighlander
2
+ class Error < StandardError; end
3
+ end
@@ -153,7 +153,7 @@ module Cfhighlander
153
153
 
154
154
 
155
155
  # evaluate template file and load parent if defined
156
- evaluateHiglanderTemplate
156
+ evaluateHighlanderTemplate
157
157
 
158
158
  # set version if not defined
159
159
  @highlander_dsl.ComponentVersion(@version) unless @version.nil?
@@ -223,7 +223,7 @@ module Cfhighlander
223
223
  end
224
224
  end
225
225
 
226
- def evaluateHiglanderTemplate
226
+ def evaluateHighlanderTemplate
227
227
  loadCfndslContent
228
228
 
229
229
  cfhl_script = ''
@@ -1,6 +1,6 @@
1
1
  require_relative './cfhighlander.compiler'
2
2
  require 'aws-sdk-s3'
3
- require 'uri'
3
+
4
4
  module Cfhighlander
5
5
 
6
6
  module Publisher
@@ -53,7 +53,7 @@ module Cfhighlander
53
53
  template_url = getTemplateUrl
54
54
  region = s3_bucket_region(@component.highlander_dsl.distribution_bucket)
55
55
  return "https://console.aws.amazon.com/cloudformation/home?region=#{region}#/stacks/create/review?filter=active&templateURL=" +
56
- "#{URI::encode(template_url)}&stackName=#{@component.name}"
56
+ "#{CGI::escape(template_url)}&stackName=#{@component.name}"
57
57
  end
58
58
 
59
59
  def publishFiles(file_list)
@@ -83,6 +83,16 @@ module Cfhighlander
83
83
  end
84
84
  print "\n"
85
85
 
86
+ @component.highlander_dsl.publish_artifacts.each do |artifact|
87
+ s3_key = artifact[:key].nil? ? "#{prefix}/#{version}/#{artifact[:file]}" : artifact[:key]
88
+ print "\nPublishing artifact: #{artifact[:file]} to s3://#{bucket}/#{s3_key} ..."
89
+ s3.put_object({
90
+ body: File.read(artifact[:file]),
91
+ bucket: bucket,
92
+ key: s3_key
93
+ })
94
+ print ' [OK] '
95
+ end
86
96
  end
87
97
 
88
98
  end
@@ -1,3 +1,3 @@
1
1
  module Cfhighlander
2
- VERSION="0.12.4".freeze
2
+ VERSION="0.12.7".freeze
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require_relative '../cfhighlander.model.component'
2
+ require_relative '../cfhighlander.error'
2
3
  require_relative './debug.util'
3
4
  require 'duplicate'
4
5
 
@@ -57,7 +58,6 @@ module Cfhighlander
57
58
  template.subcomponents.each do |sub_component|
58
59
  next unless sub_component.inlined
59
60
  model = sub_component.component_loaded.cfn_model_raw
60
-
61
61
  model[element_type].keys.each do |key|
62
62
  if keys_taken.include? key
63
63
  candidate = "#{sub_component.component_loaded.name}#{key}"
@@ -109,6 +109,16 @@ module Cfhighlander
109
109
  next unless sub_component.inlined
110
110
  model = sub_component.component_loaded.cfn_model_raw
111
111
  model[element_name].each do |resource, value|
112
+ if sub_component.conditional
113
+ # If the resource already has a conditon we need to combine it with the stack condition
114
+ if element_name == 'Conditions'
115
+ value = { "Fn::And" => [{"Condtion" => sub_component.condition}, value]}
116
+ end
117
+ # Adds the condition to the inlined resource if it doesn't already have a condition
118
+ if element_name == 'Resources'
119
+ value['Condition'] = sub_component.condition unless value.has_key?('Condition')
120
+ end
121
+ end
112
122
  # effective extraction of child resource into parent
113
123
  # allows for line components to use - or _ in the component name
114
124
  # and still generate valid references
@@ -295,6 +305,11 @@ module Cfhighlander
295
305
  outval_refs.each do |out_ref|
296
306
  component_name = out_ref[:component]
297
307
  ref_sub_component = template.subcomponents.find {|sc| sc.name == component_name}
308
+
309
+ if ref_sub_component.nil?
310
+ raise Cfhighlander::Error, "unable to find outputs from component #{component_name} reference by parameters in component #{sub_component.name}"
311
+ end
312
+
298
313
  if ref_sub_component.inlined
299
314
  # out refs here need to be replaced with actual values
300
315
  replacement = output_values[out_ref[:component]][out_ref[:outputName]]
@@ -42,7 +42,11 @@ CloudFormation do
42
42
  <% for @param in dsl.parameters.param_list %>
43
43
  Parameter('<%= @param.name %>') do
44
44
  Type '<%= @param.type %>'
45
+ <%- if ['Number', 'List<Number>'].include?(@param.type) -%>
46
+ Default <%= @param.default_value %>
47
+ <%- else -%>
45
48
  Default '<%= @param.default_value %>'
49
+ <%- end -%>
46
50
  <%- unless @param.no_echo.nil? -%>
47
51
  NoEcho <%= @param.no_echo %>
48
52
  <%- end -%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfhighlander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.12.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikola Tosic
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-03-26 00:00:00.000000000 Z
13
+ date: 2022-03-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
@@ -247,6 +247,7 @@ files:
247
247
  - lib/cfhighlander.dsl.params.rb
248
248
  - lib/cfhighlander.dsl.subcomponent.rb
249
249
  - lib/cfhighlander.dsl.template.rb
250
+ - lib/cfhighlander.error.rb
250
251
  - lib/cfhighlander.factory.rb
251
252
  - lib/cfhighlander.factory.templatefinder.rb
252
253
  - lib/cfhighlander.helper.rb
@@ -281,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
282
  - !ruby/object:Gem::Version
282
283
  version: '0'
283
284
  requirements: []
284
- rubygems_version: 3.0.8
285
+ rubygems_version: 3.1.6
285
286
  signing_key:
286
287
  specification_version: 4
287
288
  summary: DSL on top of cfndsl. Manage libraries of cloudformation components