cloudformation-tool 1.0.9 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cabf54063c7c094f182862caac32e359c495e0a8d45bac807b0bef972cc090c
|
4
|
+
data.tar.gz: a46b8080f9d6cdd042d604b70cc189ea41b0a1cb2b77ba77055fa52635e4995c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9d2d2334c8d8b242595523b7fb233b2bba9060b9ba68d8efbc1ee2516bcd5793752898682ce20a00dd7980c0f3b370bd4c82d39ef7c588ea35c2761a71af589
|
7
|
+
data.tar.gz: 57f3ec6288140dc0343b24074b670fb7a7fab1ae179418fc7f70cdb8a88e444c6e294ec919ee58a12f8cd1c67649cd20de987bc2d254e31313356cb630310e29
|
@@ -81,6 +81,16 @@ module CloudFormationTool
|
|
81
81
|
return data
|
82
82
|
end
|
83
83
|
end
|
84
|
+
|
85
|
+
def embed_includes_future
|
86
|
+
(@data.delete(@data.keys.find{|k| k.start_with? 'Include'}) || []).each do |path|
|
87
|
+
case path
|
88
|
+
when Hash
|
89
|
+
when String
|
90
|
+
embed_included_path path
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
84
94
|
|
85
95
|
def embed_includes
|
86
96
|
(@data.delete(@data.keys.find{|k| k.start_with? 'Include'}) || []).each do |path|
|
@@ -169,7 +179,7 @@ module CloudFormationTool
|
|
169
179
|
end
|
170
180
|
when 'AWS::Lambda::Function'
|
171
181
|
if key == 'Code'
|
172
|
-
LambdaCode.new(val, self).to_cloudformation
|
182
|
+
LambdaCode.new(val, self, data['Runtime']).to_cloudformation
|
173
183
|
else
|
174
184
|
load_files(val, restype)
|
175
185
|
end
|
@@ -7,33 +7,62 @@ module CloudFormationTool
|
|
7
7
|
class LambdaCode
|
8
8
|
include Storable
|
9
9
|
|
10
|
-
def initialize(code, tpl)
|
10
|
+
def initialize(code, tpl, runtime = nil)
|
11
|
+
@tpl = tpl
|
12
|
+
@zipfile_safe = runtime.to_s.match(%r{^(nodejs|python)}) != nil
|
11
13
|
@data = code
|
12
14
|
@data['Url'] = @data.delete 'URL' if @data.key? 'URL' # normalize to CF convention if seeing old key
|
13
15
|
if @data.key? 'Url'
|
14
|
-
|
15
|
-
@data['Url'] = url = tpl.resolveVal(@data['Url'])
|
16
|
-
return unless url.is_a? String
|
17
|
-
log "Downloading Lambda code from #{url}"
|
18
|
-
if already_in_cache(url)
|
19
|
-
debug "Reusing remote cached object instead of downloading"
|
20
|
-
else
|
21
|
-
res = fetch_from_url(url)
|
22
|
-
@s3_url = URI(upload(make_filename(url.split('.').last), res.body, mime_type: res['content-type'], gzip: false))
|
23
|
-
log "uploaded Lambda function to #{@s3_url}"
|
24
|
-
end
|
16
|
+
handl_url
|
25
17
|
elsif @data.key? 'Path'
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
18
|
+
handle_path
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def handle_url
|
23
|
+
debug "Trying Lambda code from #{@data['Url']}"
|
24
|
+
@data['Url'] = url = @tpl.resolveVal(@data['Url'])
|
25
|
+
return unless url.is_a? String
|
26
|
+
log "Downloading Lambda code from #{url}"
|
27
|
+
if already_in_cache(url)
|
28
|
+
debug "Reusing remote cached object instead of downloading"
|
29
|
+
else
|
30
|
+
res = fetch_from_url(url)
|
31
|
+
@s3_url = URI(upload(make_filename(url.split('.').last), res.body, mime_type: res['content-type'], gzip: false))
|
32
|
+
log "uploaded Lambda function to #{@s3_url}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def handle_path
|
37
|
+
@data['Path'] = path = @tpl.resolveVal(@data['Path'])
|
38
|
+
return unless path.is_a? String
|
39
|
+
debug "Reading Lambda code from #{path}"
|
40
|
+
path = if path.start_with? "/" then path else "#{@tpl.basedir}/#{path}" end
|
41
|
+
if File.directory?(path)
|
42
|
+
@s3_url = URI(upload(make_filename('zip'), zip_path(path), mime_type: 'application/zip', gzip: false))
|
43
|
+
log "uploaded Lambda function to #{@s3_url}"
|
44
|
+
else
|
45
|
+
handle_file path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle_file(path)
|
50
|
+
@data.delete 'Path'
|
51
|
+
contents = File.read(path)
|
52
|
+
if contents.size <= 4096 and @zipfile_safe # Convert files to ZipFile
|
53
|
+
@data['ZipFile'] = contents
|
54
|
+
else # upload and hope for the best
|
55
|
+
ext = path.split('.').last
|
56
|
+
ctype = case ext
|
57
|
+
when 'jar'
|
58
|
+
'application/java-archive'
|
59
|
+
when 'zip'
|
60
|
+
'application/zip'
|
61
|
+
else
|
62
|
+
'application/octet-stream'
|
36
63
|
end
|
64
|
+
@s3_url = URI(upload(make_filename(ext), contents, mime_type: ctype, gzip: false))
|
65
|
+
log "uploaded Lambda function to #{@s3_url}"
|
37
66
|
end
|
38
67
|
end
|
39
68
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudformation-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oded Arbel
|
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
177
|
version: '0'
|
178
178
|
requirements: []
|
179
179
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.7.
|
180
|
+
rubygems_version: 2.7.8
|
181
181
|
signing_key:
|
182
182
|
specification_version: 4
|
183
183
|
summary: A pre-compiler tool for CloudFormation YAML templates
|