cloudformation-tool 0.5.3 → 0.5.4

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
  SHA1:
3
- metadata.gz: 0d6df3ead350e6fd11b17b895205f11f75d2d407
4
- data.tar.gz: 90cfb46a70a3891ca0d000a13bdc3782d5245d69
3
+ metadata.gz: 719d1392da88b04a9b1ac703e2f53e45eb4c503e
4
+ data.tar.gz: 1b5d926090a8b5354aa73340df43d8081f83a2e0
5
5
  SHA512:
6
- metadata.gz: ab7122654fa774245069decff3185e651cc84f8b05a2a2b686a10b9a054f1bb65f5f4d8af73ffed22c04786797aa1b17854ac8bf0115062982d298bbb8403b9c
7
- data.tar.gz: 2de1e21cb0a0f83b980a3586f8d68293e15017020488bd9b5cc2e1975ec2fffc439ac5288d34abf5dc379375e2a47d079cd24a04f981d4e1466b2efc6a3ebf45
6
+ metadata.gz: 418b750c8b9ab04c029ab098e1d11849dbce7e970cf51a83a38a20e1018f91cd52c11f60914bf17dab241589fa5b775ffb65b3bd6d3457a6721f465e928461c3
7
+ data.tar.gz: 3ec1c95e7b20db70f28f1b923a9b67287e64eddceebd846338feac3fdf5094a22c031d1b38602225fa84e9a65739a123b1db771056332047e4c207ea4486ecc9
@@ -10,7 +10,7 @@ module CloudFormationTool
10
10
  log "Downloading Lambda code from #{url}"
11
11
  res = fetch(url)
12
12
 
13
- @s3_url = URI(upload(make_filename(url.split('.').last), res.body, res['content-type']))
13
+ @s3_url = URI(upload(make_filename(url.split('.').last), res.body, res['content-type'], false))
14
14
  log "uploaded Lambda function to #{@s3_url}"
15
15
  end
16
16
 
@@ -46,7 +46,7 @@ module CloudFormationTool
46
46
 
47
47
  def create(template, params = {})
48
48
  tmpl = CloudFormation.parse(template).to_yaml(params)
49
- url = upload(make_filename('yaml'), tmpl)
49
+ url = upload(make_filename('yaml'), tmpl, false)
50
50
  return update(url, template, params) if exist?
51
51
  log "Creating stack '#{name}' from '#{template}' params #{params.inspect}"
52
52
  resp = awscf.create_stack({
@@ -44,12 +44,14 @@ module CloudFormationTool
44
44
 
45
45
  def encode(allow_gzip = true)
46
46
  yamlout = compile
47
+ usegzip = false
47
48
  if allow_gzip and yamlout.size > 16384 # max AWS EC2 user data size - try compressing it
48
49
  yamlout = Zlib::Deflate.new(nil, 31).deflate(yamlout, Zlib::FINISH) # 31 is the magic word to have deflate create a gzip compatible header
50
+ usegzip = true
49
51
  end
50
52
  if yamlout.size > 16384 # still to big, we should upload to S3 and create an include file
51
53
  url = upload make_filename('init'),
52
- yamlout, 'text/cloud-config'
54
+ yamlout, 'text/cloud-config', usegzip
53
55
  log "Wrote cloud config to #{url}"
54
56
  [ "#include", url ].join "\n"
55
57
  else
@@ -13,7 +13,7 @@ module CloudFormationTool
13
13
  end
14
14
  end
15
15
 
16
- def upload(path, content, mime_type = 'text/yaml')
16
+ def upload(path, content, mime_type = 'text/yaml', gziped = true)
17
17
  md5 = Digest::MD5.hexdigest content
18
18
  prefix = "#{md5[0]}/#{md5[1..2]}/#{md5}"
19
19
  b = Aws::S3::Bucket.new(s3_bucket_name(region), client: awss3(region))
@@ -26,12 +26,15 @@ module CloudFormationTool
26
26
  if o.nil?
27
27
  # no such luck, we need to actually upload the file
28
28
  o = b.object("cf-compiled/#{prefix}/#{path}")
29
- o.put acl: 'public-read',
30
- body: content,
31
- content_disposition: 'attachment',
32
- content_encoding: 'gzip',
33
- content_type: mime_type,
34
- storage_class: 'REDUCED_REDUNDANCY'
29
+ file_opts = {
30
+ acl: 'public-read',
31
+ body: content,
32
+ content_disposition: 'attachment',
33
+ content_type: mime_type,
34
+ storage_class: 'REDUCED_REDUNDANCY'
35
+ }
36
+ file_opts.merge!({content_encoding: 'gzip'}) if gziped
37
+ o.put(file_opts)
35
38
  else
36
39
  log "re-using cached object"
37
40
  end
@@ -1,3 +1,3 @@
1
1
  module CloudFormationTool
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
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: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Arbel