cfhighlander 0.12.5.alpha.1620862522 → 0.12.8

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: 5e34cde3f6ad0999503b44f5bd8fb03344d02d0eace4eed5ed0044837f62355a
4
- data.tar.gz: '0088fbf56d21e7cbd9d5f84f3039f0e383491a32e837b7eb411373e12b621273'
3
+ metadata.gz: ce9596bfe2e0a988d21ef1f23b567b7b3cd1d71f343daffe255a82bc097fbde6
4
+ data.tar.gz: 489472343feeb7a3422d37c0069f8f3c639dea0813ead2e7a1f2c8ad2cfb2829
5
5
  SHA512:
6
- metadata.gz: 0271d23aae856b674bb75bff5eca63d3004ce265042f3012f39ccb7ed76e508da04880c583934952cb03b4487f770d77f8a400c767d2cdc443d71aa5a686333a
7
- data.tar.gz: 29d8410d47e67bbaa45a7232b0f71e410e6ddaa71457576755de77a80d97317b4ef9c4bb94bf6bcff32d175181520d2d65e47972a21ddaf935d8bef46c492cc3
6
+ metadata.gz: 02bb5a53d8688683c238083bad087b9abe101d4c4a52b37f00994d16cbc87b09d21e299ba7c7ac2475b812eb62dfa37f77deae8ee9a9117598dcdadaf64e366d
7
+ data.tar.gz: 79f4cabecdf3b2b581f37072a1ff99c73f92c8ca7b74985f2c174b52f4a2b02049048112970c39d2f8c91aa9576e0f672f9608ca5a6a1e47c5f0f8918074f0fd
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.5".freeze
2
+ VERSION="0.12.8".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.5.alpha.1620862522
4
+ version: 0.12.8
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-05-12 00:00:00.000000000 Z
13
+ date: 2022-05-17 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
@@ -277,11 +278,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
278
  version: '2.7'
278
279
  required_rubygems_version: !ruby/object:Gem::Requirement
279
280
  requirements:
280
- - - ">"
281
+ - - ">="
281
282
  - !ruby/object:Gem::Version
282
- version: 1.3.1
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