kumogata 0.2.0 → 0.2.1

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: 6dba7edb943ddc60c3ba51b2280ab75963303884
4
- data.tar.gz: 71da06088335d8104b011df5771a380a6de9f1b0
3
+ metadata.gz: d994503ecb53c0aa9e0a0d7317a3f6b6cc8b2b39
4
+ data.tar.gz: cd96c9f28fdc83ba2025828f9ef5b305a3d5a313
5
5
  SHA512:
6
- metadata.gz: 2f37f6ebd3c5ff220a829e48b99eb1f5c8b506879449876dcbcf9f961324b41dedc3b1f4c925b4fe672469f98bb568d04341c6367d66dea1d1e33a72e46fe781
7
- data.tar.gz: c1d201f490a069ff328464f796cce66516b8e2159027248dbff67c2942033522108b22c21601523bc757c588a4ae1d044e463040a30449bed78648f458b16964
6
+ metadata.gz: 8392415cc172bc02adc1fb976316dfd7b7e4bdd4cde81cf6aca088a0af13480f5da9517461da3d1e8c530c1ce6a78662057a04e300706f2dda5695e046ccc621
7
+ data.tar.gz: 14a7759b1a3acfc951f3cc20ab317180972c9fe147b2f4fc7d1920cefda4b2c5d43c0f96c3e86499501404c66dec2855f279e4a6b7c4661a1e6b4aabb642ceec
data/README.md CHANGED
@@ -5,12 +5,19 @@
5
5
 
6
6
  Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
7
7
 
8
- [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403050111)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403050111)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403050220)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403050220)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
13
13
  ```ruby
14
+ AWSTemplateFormatVersion "2010-09-09"
15
+
16
+ Description (<<-EOS).undent
17
+ Kumogata Sample Template
18
+ You can use Here document!
19
+ EOS
20
+
14
21
  Parameters do
15
22
  InstanceType do
16
23
  Default "t1.micro"
@@ -123,7 +130,7 @@ JSON template can be converted to Ruby template.
123
130
 
124
131
  ### String#fn_joine()
125
132
 
126
- Ruby templates will be converted as follows by `_join()`:
133
+ Ruby templates will be converted as follows by `String#fn_join()`:
127
134
 
128
135
  ```ruby
129
136
  UserData do
@@ -46,9 +46,45 @@ class String
46
46
  null = "\0"
47
47
 
48
48
  data = Object.new.instance_eval(<<-EOS)
49
- @__refs__ = []
50
- def Ref(value); @__refs__ << {'Ref' => value}; #{null.inspect}; end
51
- ERB.new(#{data.inspect}, nil, #{trim_mode.inspect}).result(binding).split(#{null.inspect}).zip(@__refs__)
49
+ @__functions__ = []
50
+
51
+ @__value_conv__ = proc do |v|
52
+ case v
53
+ when Array, Hash
54
+ v
55
+ else
56
+ v.to_s
57
+ end
58
+ end
59
+
60
+ def Fn__Base64(value)
61
+ @__functions__ << {'Fn::Base64' => @__value_conv__[value]}
62
+ #{null.inspect}
63
+ end
64
+
65
+ def Fn__FindInMap(map_name, top_level_key, second_level_key)
66
+ @__functions__ << {'Fn::FindInMap' => [
67
+ map_name, top_level_key, second_level_key].map(&@__value_conv__)}
68
+ #{null.inspect}
69
+ end
70
+
71
+ def Fn__GetAtt(logical_name, attr_name)
72
+ @__functions__ << {'Fn::GetAtt' => [
73
+ logical_name, attr_name].map(&@__value_conv__)}
74
+ #{null.inspect}
75
+ end
76
+
77
+ def Fn__GetAZs(region)
78
+ @__functions__ << {'Fn::GetAZs' => @__value_conv__[region]}
79
+ #{null.inspect}
80
+ end
81
+
82
+ def Ref(value)
83
+ @__functions__ << {'Ref' => value}
84
+ #{null.inspect}
85
+ end
86
+
87
+ ERB.new(#{data.inspect}, nil, #{trim_mode.inspect}).result(binding).split(#{null.inspect}).zip(@__functions__)
52
88
  EOS
53
89
 
54
90
  data = data.flatten.select {|i| not i.nil? }.map {|i|
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -343,6 +343,32 @@ Resources do
343
343
  end # Metadata
344
344
  end
345
345
  end
346
+
347
+ Outputs do
348
+ WebsiteURL do
349
+ Value (<<-EOS).fn_join
350
+ http://<%= Fn__GetAtt "myEC2Instance", "PublicDnsName" %>
351
+ EOS
352
+ end
353
+
354
+ Base64Str do
355
+ Value (<<-EOS).fn_join
356
+ <%= Fn__Base64 "AWS CloudFormation" %>
357
+ EOS
358
+ end
359
+
360
+ MappedValue do
361
+ Value (<<-EOS).fn_join
362
+ <%= Fn__FindInMap "RegionMap", { "Ref" => "AWS::Region" }, 32 %>
363
+ EOS
364
+ end
365
+
366
+ AZ do
367
+ Value (<<-EOS).fn_join
368
+ <%= Fn__GetAZs "us-east-1" %>
369
+ EOS
370
+ end
371
+ end
346
372
  TEMPLATE
347
373
 
348
374
  json_template = run_client(:convert, :template => template)
@@ -421,6 +447,70 @@ end
421
447
  }
422
448
  }
423
449
  }
450
+ },
451
+ "Outputs": {
452
+ "WebsiteURL": {
453
+ "Value": {
454
+ "Fn::Join": [
455
+ "",
456
+ [
457
+ "http://",
458
+ {
459
+ "Fn::GetAtt": [
460
+ "myEC2Instance",
461
+ "PublicDnsName"
462
+ ]
463
+ },
464
+ "\n"
465
+ ]
466
+ ]
467
+ }
468
+ },
469
+ "Base64Str": {
470
+ "Value": {
471
+ "Fn::Join": [
472
+ "",
473
+ [
474
+ {
475
+ "Fn::Base64": "AWS CloudFormation"
476
+ },
477
+ "\n"
478
+ ]
479
+ ]
480
+ }
481
+ },
482
+ "MappedValue": {
483
+ "Value": {
484
+ "Fn::Join": [
485
+ "",
486
+ [
487
+ {
488
+ "Fn::FindInMap": [
489
+ "RegionMap",
490
+ {
491
+ "Ref": "AWS::Region"
492
+ },
493
+ "32"
494
+ ]
495
+ },
496
+ "\n"
497
+ ]
498
+ ]
499
+ }
500
+ },
501
+ "AZ": {
502
+ "Value": {
503
+ "Fn::Join": [
504
+ "",
505
+ [
506
+ {
507
+ "Fn::GetAZs": "us-east-1"
508
+ },
509
+ "\n"
510
+ ]
511
+ ]
512
+ }
513
+ }
424
514
  }
425
515
  }
426
516
  EOS
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara