jets 0.8.18 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +20 -1
- data/Gemfile.lock +6 -2
- data/README/prerelease.md +6 -0
- data/README/testing.md +41 -0
- data/Rakefile +9 -1
- data/jets.gemspec +1 -0
- data/lib/jets.rb +17 -18
- data/lib/jets/application.rb +26 -3
- data/lib/jets/aws_services.rb +26 -59
- data/lib/jets/aws_services/stack_status.rb +52 -0
- data/lib/jets/builders.rb +3 -2
- data/lib/jets/builders/handler_generator.rb +38 -2
- data/lib/jets/builders/shared_deducer.rb +32 -0
- data/lib/jets/cfn/builders.rb +3 -1
- data/lib/jets/cfn/builders/api_deployment_builder.rb +1 -1
- data/lib/jets/cfn/builders/api_gateway_builder.rb +1 -1
- data/lib/jets/cfn/builders/base_child_builder.rb +37 -7
- data/lib/jets/cfn/builders/controller_builder.rb +6 -1
- data/lib/jets/cfn/builders/function_builder.rb +5 -0
- data/lib/jets/cfn/builders/interface.rb +5 -6
- data/lib/jets/cfn/builders/job_builder.rb +5 -0
- data/lib/jets/cfn/builders/parent_builder.rb +17 -16
- data/lib/jets/cfn/builders/rule_builder.rb +6 -1
- data/lib/jets/cfn/builders/shared_builder.rb +14 -0
- data/lib/jets/commands.rb +9 -8
- data/lib/jets/commands/build.rb +36 -14
- data/lib/jets/commands/console.rb +1 -0
- data/lib/jets/commands/help/runner.md +17 -0
- data/lib/jets/commands/main.rb +7 -0
- data/lib/jets/commands/new.rb +39 -19
- data/lib/jets/commands/runner.rb +18 -0
- data/lib/jets/commands/sequence.rb +27 -1
- data/lib/jets/commands/templates/skeleton/.rspec +3 -0
- data/lib/jets/commands/templates/skeleton/Gemfile.tt +0 -1
- data/lib/jets/commands/templates/skeleton/app/jobs/application_job.rb +2 -0
- data/lib/jets/commands/templates/skeleton/config/application.rb.tt +2 -1
- data/lib/jets/commands/templates/skeleton/config/routes.rb +5 -1
- data/lib/jets/commands/templates/skeleton/spec/spec_helper.rb.tt +5 -4
- data/lib/jets/core.rb +8 -6
- data/lib/jets/default/application.rb +1 -0
- data/lib/jets/generator.rb +1 -1
- data/lib/jets/inflections.rb +23 -0
- data/lib/jets/job/dsl.rb +69 -47
- data/lib/jets/klass.rb +6 -1
- data/lib/jets/lambda/dsl.rb +102 -34
- data/lib/jets/lambda/function_constructor.rb +2 -2
- data/lib/jets/lambda/task.rb +10 -5
- data/lib/jets/naming.rb +13 -2
- data/lib/jets/processors/deducer.rb +13 -2
- data/lib/jets/processors/main_processor.rb +1 -1
- data/lib/jets/rails_overrides.rb +1 -1
- data/lib/jets/resource.rb +20 -5
- data/lib/jets/resource/api_gateway/deployment.rb +0 -1
- data/lib/jets/resource/associated.rb +26 -0
- data/lib/jets/resource/base.rb +12 -0
- data/lib/jets/resource/child_stack.rb +2 -0
- data/lib/jets/resource/child_stack/api_deployment.rb +9 -15
- data/lib/jets/resource/child_stack/api_gateway.rb +8 -8
- data/lib/jets/resource/child_stack/app_class.rb +41 -16
- data/lib/jets/resource/child_stack/base.rb +24 -0
- data/lib/jets/resource/child_stack/shared.rb +90 -0
- data/lib/jets/resource/config.rb +4 -0
- data/lib/jets/resource/config/config_rule.rb +66 -0
- data/lib/jets/resource/config/managed_rule.rb +15 -0
- data/lib/jets/resource/events.rb +3 -0
- data/lib/jets/resource/events/rule.rb +31 -0
- data/lib/jets/resource/iam/application_role.rb +2 -2
- data/lib/jets/resource/iam/base_role_definition.rb +4 -2
- data/lib/jets/resource/iam/class_role.rb +50 -2
- data/lib/jets/resource/iam/function_role.rb +28 -0
- data/lib/jets/resource/iam/policy_document.rb +0 -4
- data/lib/jets/resource/permission.rb +12 -6
- data/lib/jets/resource/replacer.rb +4 -0
- data/lib/jets/resource/sns.rb +3 -0
- data/lib/jets/resource/standardizer.rb +42 -0
- data/lib/jets/router.rb +9 -1
- data/lib/jets/rule/dsl.rb +51 -78
- data/lib/jets/stack.rb +105 -0
- data/lib/jets/stack/builder.rb +38 -0
- data/lib/jets/stack/definition.rb +50 -0
- data/lib/jets/stack/function.rb +60 -0
- data/lib/jets/stack/main.rb +5 -0
- data/lib/jets/stack/main/dsl.rb +33 -0
- data/lib/jets/stack/main/extensions/base.rb +45 -0
- data/lib/jets/stack/main/extensions/cloudwatch.rb +19 -0
- data/lib/jets/stack/main/extensions/lambda.rb +69 -0
- data/lib/jets/stack/main/extensions/sns.rb +12 -0
- data/lib/jets/stack/main/extensions/sqs.rb +8 -0
- data/lib/jets/stack/output.rb +38 -0
- data/lib/jets/stack/output/dsl.rb +19 -0
- data/lib/jets/stack/output/lookup.rb +36 -0
- data/lib/jets/stack/parameter.rb +38 -0
- data/lib/jets/stack/parameter/dsl.rb +42 -0
- data/lib/jets/stack/resource.rb +30 -0
- data/lib/jets/stack/resource/dsl.rb +19 -0
- data/lib/jets/version.rb +1 -1
- metadata +53 -4
- data/support/clean +0 -3
- data/support/console +0 -3
data/lib/jets/klass.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
# Jets::Klass.from_path("app/jobs/hard_job.rb")
|
16
16
|
# Jets::Klass.from_path("app/functions/hello.rb")
|
17
17
|
# Jets::Klass.from_path("app/functions/hello_function.rb")
|
18
|
+
# Jets::Klass.from_path("app/shared/functions/whatever.rb")
|
18
19
|
#
|
19
20
|
# Jets::Klass.from_task(task)
|
20
21
|
#
|
@@ -37,7 +38,11 @@ class Jets::Klass
|
|
37
38
|
|
38
39
|
# app/controllers/posts_controller.rb => PostsController
|
39
40
|
def class_name(path)
|
40
|
-
path.
|
41
|
+
if path.include?("/shared/")
|
42
|
+
path.sub(%r{.*app/shared/(.*?)/},'').sub(/\.rb$/,'').classify
|
43
|
+
else
|
44
|
+
path.sub(%r{.*app/(.*?)/},'').sub(/\.rb$/,'').classify
|
45
|
+
end
|
41
46
|
end
|
42
47
|
|
43
48
|
def from_task(task)
|
data/lib/jets/lambda/dsl.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
1
3
|
# Other dsl that rely on this must implement
|
2
|
-
#
|
4
|
+
#
|
5
|
+
# default_associated_resource_definition
|
6
|
+
#
|
3
7
|
module Jets::Lambda::Dsl
|
4
8
|
extend ActiveSupport::Concern
|
5
9
|
|
@@ -130,41 +134,67 @@ module Jets::Lambda::Dsl
|
|
130
134
|
end
|
131
135
|
|
132
136
|
#############################
|
133
|
-
# Main
|
137
|
+
# Main method that registers resources associated with the Lambda function.
|
134
138
|
# All resources methods lead here.
|
135
|
-
def
|
136
|
-
if definitions == [nil] # when
|
137
|
-
@
|
139
|
+
def associated_resources(*definitions)
|
140
|
+
if definitions == [nil] # when associated_resources called with no arguments
|
141
|
+
@associated_resources || []
|
138
142
|
else
|
139
|
-
@
|
140
|
-
@
|
141
|
-
@
|
143
|
+
@associated_resources ||= []
|
144
|
+
@associated_resources << Jets::Resource::Associated.new(definitions)
|
145
|
+
@associated_resources.flatten!
|
142
146
|
end
|
143
147
|
end
|
144
|
-
|
148
|
+
# User-friendly short resource method. Users will use this.
|
149
|
+
alias_method :resource, :associated_resources
|
145
150
|
|
146
|
-
#
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
#
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
151
|
+
# Properties belonging to the associated resource
|
152
|
+
def associated_properties(options={})
|
153
|
+
@associated_properties ||= {}
|
154
|
+
@associated_properties.deep_merge!(options)
|
155
|
+
end
|
156
|
+
alias_method :associated_props, :associated_properties
|
157
|
+
|
158
|
+
# meta definition
|
159
|
+
def self.define_associated_properties(associated_properties)
|
160
|
+
associated_properties.each do |property|
|
161
|
+
# Example:
|
162
|
+
# def config_rule_name(value)
|
163
|
+
# associated_properties(config_rule_name: value)
|
164
|
+
# end
|
165
|
+
class_eval <<~CODE
|
166
|
+
def #{property}(value)
|
167
|
+
associated_properties(#{property}: value)
|
168
|
+
end
|
169
|
+
CODE
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# Loop back through the resources and add a counter to the end of the id
|
174
|
+
# to handle multiple events.
|
175
|
+
# Then replace @associated_resources entirely
|
176
|
+
def add_logical_id_counter
|
177
|
+
numbered_resources = []
|
178
|
+
n = 1
|
179
|
+
@associated_resources.map do |associated|
|
180
|
+
logical_id = associated.logical_id
|
181
|
+
attributes = associated.attributes
|
182
|
+
|
183
|
+
logical_id = logical_id.sub(/\d+$/,'')
|
184
|
+
new_definition = { "#{logical_id}#{n}" => attributes }
|
185
|
+
numbered_resources << Jets::Resource::Associated.new(new_definition)
|
186
|
+
n += 1
|
187
|
+
end
|
188
|
+
@associated_resources = numbered_resources
|
189
|
+
end
|
190
|
+
|
191
|
+
def depends_on(*stacks)
|
192
|
+
if stacks == []
|
193
|
+
@depends_on
|
194
|
+
else
|
195
|
+
@depends_on ||= []
|
196
|
+
@depends_on += stacks
|
197
|
+
end
|
168
198
|
end
|
169
199
|
|
170
200
|
# meth is a Symbol
|
@@ -179,12 +209,26 @@ module Jets::Lambda::Dsl
|
|
179
209
|
# Note: for anonymous classes like for app/functions self.name is ""
|
180
210
|
# We adjust the class name when we build the functions later in
|
181
211
|
# FunctionContstructor#adjust_tasks.
|
212
|
+
|
213
|
+
# At this point we can use the current associated_properties and defined the
|
214
|
+
# associated resource with the Lambda function.
|
215
|
+
unless associated_properties.empty?
|
216
|
+
associated_resources(default_associated_resource_definition(meth))
|
217
|
+
end
|
218
|
+
|
219
|
+
# Unsure why but we have to use @associated_resources vs associated_resources
|
220
|
+
# associated_resources is always nil
|
221
|
+
if @associated_resources && @associated_resources.size > 1
|
222
|
+
add_logical_id_counter
|
223
|
+
end
|
224
|
+
|
182
225
|
all_tasks[meth] = Jets::Lambda::Task.new(self.name, meth,
|
183
|
-
resources: @resources, # associated resources
|
184
226
|
properties: @properties, # lambda function properties
|
185
227
|
iam_policy: @iam_policy,
|
186
228
|
managed_iam_policy: @managed_iam_policy,
|
187
|
-
|
229
|
+
associated_resources: @associated_resources,
|
230
|
+
lang: lang,
|
231
|
+
replacements: replacements(meth))
|
188
232
|
|
189
233
|
# Done storing options, clear out for the next added method.
|
190
234
|
clear_properties
|
@@ -199,11 +243,16 @@ module Jets::Lambda::Dsl
|
|
199
243
|
true
|
200
244
|
end
|
201
245
|
|
246
|
+
# Meant to be overridden to add more custom replacements based on the app class type
|
247
|
+
def replacements(meth)
|
248
|
+
{}
|
249
|
+
end
|
250
|
+
|
202
251
|
def clear_properties
|
203
|
-
@resources = nil
|
204
252
|
@properties = nil
|
205
253
|
@iam_policy = nil
|
206
254
|
@managed_iam_policy = nil
|
255
|
+
@associated_resources = nil
|
207
256
|
end
|
208
257
|
|
209
258
|
# Returns the all tasks for this class with their method names as keys.
|
@@ -252,6 +301,25 @@ module Jets::Lambda::Dsl
|
|
252
301
|
def node(meth)
|
253
302
|
defpoly(:node, meth)
|
254
303
|
end
|
304
|
+
end # end of class << self
|
305
|
+
end # end of included
|
306
|
+
|
307
|
+
def self.add_custom_resource_extensions(base)
|
308
|
+
base_path = "#{Jets.root}/app/extensions"
|
309
|
+
unless ActiveSupport::Dependencies.autoload_paths.include?(base_path)
|
310
|
+
ActiveSupport::Dependencies.autoload_paths += [base_path]
|
255
311
|
end
|
312
|
+
|
313
|
+
Dir.glob("#{base_path}/**/*.rb").each do |path|
|
314
|
+
next unless File.file?(path)
|
315
|
+
|
316
|
+
class_name = path.sub("#{base_path}/", '').sub(/\.rb/,'').classify
|
317
|
+
klass = class_name.constantize # autoload
|
318
|
+
base.extend(klass)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
def self.included(base)
|
323
|
+
add_custom_resource_extensions(base)
|
256
324
|
end
|
257
325
|
end
|
@@ -45,10 +45,10 @@ module Jets::Lambda
|
|
45
45
|
function_klass # assign this to a Constant for a pretty class name
|
46
46
|
end
|
47
47
|
|
48
|
-
# For anonymous classes method_added during task
|
48
|
+
# For anonymous classes method_added during task registration contains ""
|
49
49
|
# for the class name. We adjust it here.
|
50
50
|
def adjust_tasks(klass)
|
51
|
-
class_name = @code_path.sub(
|
51
|
+
class_name = @code_path.sub(/.*\/functions\//,'').sub(/\.rb$/, '')
|
52
52
|
class_name = class_name.classify
|
53
53
|
klass.tasks.each do |task|
|
54
54
|
task.class_name = class_name
|
data/lib/jets/lambda/task.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
class Jets::Lambda::Task
|
2
2
|
attr_accessor :class_name, :type
|
3
|
-
attr_reader :meth, :
|
3
|
+
attr_reader :meth, :properties, :iam_policy, :managed_iam_policy, :lang, :associated_resources
|
4
4
|
def initialize(class_name, meth, options={})
|
5
5
|
@class_name = class_name.to_s
|
6
6
|
@meth = meth
|
7
7
|
@options = options
|
8
8
|
@type = options[:type] || get_type # controller, job, or function
|
9
|
-
@resources = options[:resources] || {}
|
10
9
|
@properties = options[:properties] || {}
|
11
10
|
@iam_policy = options[:iam_policy]
|
12
11
|
@managed_iam_policy = options[:managed_iam_policy]
|
13
12
|
@lang = options[:lang] || :ruby
|
13
|
+
@associated_resources = options[:associated_resources] || {}
|
14
|
+
@replacements = options[:replacements] || {} # added to baseline replacements
|
14
15
|
end
|
15
16
|
|
16
17
|
def build_function_iam?
|
@@ -82,11 +83,15 @@ class Jets::Lambda::Task
|
|
82
83
|
handler_path.sub("handlers/", "app/")
|
83
84
|
end
|
84
85
|
|
85
|
-
###
|
86
|
-
# Useful for Jets::Resource late building.
|
87
86
|
def replacements
|
87
|
+
# Merge in the custom replacements specific to each app class: ConfigRule, Job, etc.
|
88
|
+
baseline_replacements.merge(@replacements)
|
89
|
+
end
|
90
|
+
|
91
|
+
def baseline_replacements
|
88
92
|
{
|
89
|
-
|
93
|
+
# camelized because used in not just keys but common used in values
|
94
|
+
namespace: @meth.to_s.camelize,
|
90
95
|
}
|
91
96
|
end
|
92
97
|
end
|
data/lib/jets/naming.rb
CHANGED
@@ -4,9 +4,16 @@
|
|
4
4
|
class Jets::Naming
|
5
5
|
# Mainly used by build.rb
|
6
6
|
class << self
|
7
|
-
|
7
|
+
extend Memoist
|
8
|
+
|
9
|
+
def app_template_path(app_class)
|
8
10
|
underscored = app_class.to_s.underscore.gsub('/','-')
|
9
|
-
"#{template_path_prefix}-#{underscored}.yml"
|
11
|
+
"#{template_path_prefix}-app-#{underscored}.yml"
|
12
|
+
end
|
13
|
+
|
14
|
+
def shared_template_path(shared_class)
|
15
|
+
underscored = shared_class.to_s.underscore.gsub('/','-')
|
16
|
+
"#{template_path_prefix}-shared-#{underscored}.yml"
|
10
17
|
end
|
11
18
|
|
12
19
|
def template_path_prefix
|
@@ -27,6 +34,10 @@ class Jets::Naming
|
|
27
34
|
"#{template_path_prefix}-api-deployment.yml"
|
28
35
|
end
|
29
36
|
|
37
|
+
def shared_resources_template_path
|
38
|
+
"#{template_path_prefix}-shared-resources.yml"
|
39
|
+
end
|
40
|
+
|
30
41
|
def parent_stack_name
|
31
42
|
File.basename(parent_template_path, ".yml")
|
32
43
|
end
|
@@ -27,14 +27,25 @@ class Jets::Processors::Deducer
|
|
27
27
|
# process_type is key. It can be either "controller" or "job". It is used to
|
28
28
|
# deduce the rest of the methods: code, path.
|
29
29
|
def process_type
|
30
|
-
|
30
|
+
if shared?
|
31
|
+
"function" # all app/shared/functions are always function process_type
|
32
|
+
else
|
33
|
+
@handler.split('/')[1].singularize # controller, job, rule, etc
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def shared?
|
38
|
+
@handler.include?("/shared/functions")
|
31
39
|
end
|
32
40
|
|
33
41
|
# Example underscored_class_name:
|
34
42
|
# class_name = underscored_class_name
|
35
43
|
# class_name = class_name # PostsController
|
36
44
|
def class_name
|
37
|
-
regexp =
|
45
|
+
regexp = shared? ?
|
46
|
+
Regexp.new(".*handlers/shared/functions/") :
|
47
|
+
Regexp.new(".*handlers/#{process_type.pluralize}/")
|
48
|
+
|
38
49
|
# Example regexp:
|
39
50
|
# /.*handlers\/controllers\//
|
40
51
|
# /.*handlers\/jobs\//
|
@@ -44,7 +44,7 @@ class Jets::Processors::MainProcessor
|
|
44
44
|
#
|
45
45
|
# JSON.dump is pretty robust. If it cannot dump the structure into a
|
46
46
|
# json string, it just dumps it to a plain text string.
|
47
|
-
|
47
|
+
Jets::Util.normalize_result(result) # resp is a String
|
48
48
|
rescue Exception => e
|
49
49
|
# Customize error message slightly so nodejs shim can process the
|
50
50
|
# returned error message.
|
data/lib/jets/rails_overrides.rb
CHANGED
data/lib/jets/resource.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
class Jets::Resource
|
2
2
|
extend Memoist
|
3
3
|
|
4
|
-
autoload :Base, 'jets/resource/base'
|
5
|
-
autoload :Replacer, 'jets/resource/replacer'
|
6
|
-
autoload :Permission, 'jets/resource/permission'
|
7
4
|
autoload :ApiGateway, 'jets/resource/api_gateway'
|
5
|
+
autoload :Associated, 'jets/resource/associated'
|
6
|
+
autoload :Base, 'jets/resource/base'
|
8
7
|
autoload :ChildStack, 'jets/resource/child_stack'
|
8
|
+
autoload :Config, 'jets/resource/config'
|
9
|
+
autoload :Events, 'jets/resource/events'
|
9
10
|
autoload :Function, 'jets/resource/function'
|
10
11
|
autoload :Iam, 'jets/resource/iam'
|
12
|
+
autoload :Permission, 'jets/resource/permission'
|
13
|
+
autoload :Replacer, 'jets/resource/replacer'
|
11
14
|
autoload :S3, 'jets/resource/s3'
|
15
|
+
autoload :Sns, 'jets/resource/sns'
|
16
|
+
autoload :Standardizer, 'jets/resource/standardizer'
|
12
17
|
|
13
18
|
attr_reader :definition, :replacements
|
14
19
|
def initialize(definition, replacements={})
|
@@ -16,8 +21,18 @@ class Jets::Resource
|
|
16
21
|
@replacements = replacements
|
17
22
|
end
|
18
23
|
|
24
|
+
def template
|
25
|
+
standarize(definition)
|
26
|
+
end
|
27
|
+
memoize :template
|
28
|
+
|
29
|
+
# CloudFormation Resources reference: https://amzn.to/2NKg6ip
|
30
|
+
def standarize(*definition)
|
31
|
+
Standardizer.new(definition).template
|
32
|
+
end
|
33
|
+
|
19
34
|
def logical_id
|
20
|
-
id =
|
35
|
+
id = template.keys.first
|
21
36
|
# replace possible {namespace} in the logical id
|
22
37
|
id = replacer.replace_value(id)
|
23
38
|
Jets::Camelizer.camelize(id)
|
@@ -32,7 +47,7 @@ class Jets::Resource
|
|
32
47
|
end
|
33
48
|
|
34
49
|
def attributes
|
35
|
-
attributes =
|
50
|
+
attributes = template.values.first
|
36
51
|
attributes = replacer.replace_placeholders(attributes)
|
37
52
|
Jets::Camelizer.transform(attributes)
|
38
53
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Does not do full expansion, mainly a container that holds the definition and
|
2
|
+
# standardizes it without camelizing it.
|
3
|
+
class Jets::Resource
|
4
|
+
class Associated
|
5
|
+
extend Memoist
|
6
|
+
|
7
|
+
attr_reader :definition
|
8
|
+
def initialize(*definition)
|
9
|
+
@definition = definition.flatten
|
10
|
+
end
|
11
|
+
|
12
|
+
def logical_id
|
13
|
+
standardized.keys.first
|
14
|
+
end
|
15
|
+
|
16
|
+
def attributes
|
17
|
+
standardized.values.first
|
18
|
+
end
|
19
|
+
|
20
|
+
def standardized
|
21
|
+
standardizer = Standardizer.new(definition)
|
22
|
+
standardizer.standarize(definition) # doesnt camelize keys yet
|
23
|
+
end
|
24
|
+
memoize :standardized
|
25
|
+
end
|
26
|
+
end
|
data/lib/jets/resource/base.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# Classes that inherit from this method should NOT define and override:
|
2
|
+
#
|
3
|
+
# logical_id
|
4
|
+
# type
|
5
|
+
# properties
|
6
|
+
# attributes
|
7
|
+
#
|
8
|
+
# These are computed methods that derive their values from the resource definition itself.
|
9
|
+
# Overriding these methods will remove the computed logical which handles things
|
10
|
+
# like camelizing and replacements.
|
11
|
+
#
|
12
|
+
# The implementation of these methods are in `Jets::Resource`.
|
1
13
|
class Jets::Resource
|
2
14
|
class Base
|
3
15
|
extend Memoist
|
@@ -2,4 +2,6 @@ module Jets::Resource::ChildStack
|
|
2
2
|
autoload :AppClass, 'jets/resource/child_stack/app_class'
|
3
3
|
autoload :ApiGateway, 'jets/resource/child_stack/api_gateway'
|
4
4
|
autoload :ApiDeployment, 'jets/resource/child_stack/api_deployment'
|
5
|
+
autoload :Base, 'jets/resource/child_stack/base'
|
6
|
+
autoload :Shared, 'jets/resource/child_stack/shared'
|
5
7
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# Implements:
|
2
|
+
#
|
3
|
+
# definition
|
4
|
+
# template_filename
|
5
|
+
#
|
1
6
|
module Jets::Resource::ChildStack
|
2
|
-
class ApiDeployment <
|
3
|
-
def initialize(s3_bucket)
|
4
|
-
@s3_bucket = s3_bucket
|
5
|
-
end
|
6
|
-
|
7
|
+
class ApiDeployment < Base
|
7
8
|
def definition
|
8
9
|
{
|
9
10
|
deployment_id => {
|
@@ -32,7 +33,7 @@ module Jets::Resource::ChildStack
|
|
32
33
|
# map the path to a camelized logical_id. Example:
|
33
34
|
# /tmp/jets/demo/templates/demo-dev-2-posts_controller.yml to
|
34
35
|
# PostsController
|
35
|
-
regexp = Regexp.new(".*#{Jets.config.project_namespace}-")
|
36
|
+
regexp = Regexp.new(".*#{Jets.config.project_namespace}-app-")
|
36
37
|
controller_name = path.sub(regexp, '').sub('.yml', '')
|
37
38
|
controller_logical_id = controller_name.underscore.camelize
|
38
39
|
controller_logical_ids << controller_logical_id
|
@@ -40,19 +41,12 @@ module Jets::Resource::ChildStack
|
|
40
41
|
controller_logical_ids
|
41
42
|
end
|
42
43
|
|
43
|
-
def outputs
|
44
|
-
{
|
45
|
-
logical_id => "!Ref #{logical_id}",
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
44
|
def deployment_id
|
50
45
|
Jets::Resource::ApiGateway::Deployment.logical_id
|
51
46
|
end
|
52
47
|
|
53
|
-
def
|
54
|
-
|
55
|
-
"https://s3.amazonaws.com/#{@s3_bucket}/jets/cfn-templates/#{path}"
|
48
|
+
def template_filename
|
49
|
+
"#{Jets.config.project_namespace}-api-deployment.yml"
|
56
50
|
end
|
57
51
|
end
|
58
52
|
end
|