kumogata-template 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +19 -19
  3. data/lib/kumogata/template/alb.rb +99 -0
  4. data/lib/kumogata/template/certificate.rb +18 -0
  5. data/lib/kumogata/template/const.rb +7 -0
  6. data/lib/kumogata/template/ec2.rb +6 -0
  7. data/lib/kumogata/template/ecs.rb +9 -0
  8. data/lib/kumogata/template/ext/kumogata.rb +5 -6
  9. data/lib/kumogata/template/helper.rb +4 -0
  10. data/lib/kumogata/template/version.rb +1 -1
  11. data/lib/kumogata/template.rb +2 -0
  12. data/template/alb-listener-rule.rb +22 -0
  13. data/template/alb-listener.rb +26 -0
  14. data/template/alb-load-balancer.rb +27 -0
  15. data/template/alb-target-group.rb +39 -0
  16. data/template/autoscaling-group.rb +2 -0
  17. data/template/certificate.rb +20 -0
  18. data/template/ec2-flow-log.rb +41 -0
  19. data/template/ec2-host.rb +21 -0
  20. data/template/ec2-instance.rb +5 -1
  21. data/template/ec2-spot-fleet.rb +16 -0
  22. data/template/ecs-service.rb +2 -0
  23. data/template/{elb-loadbalancer.rb → elb-load-balancer.rb} +1 -1
  24. data/template/iam-group.rb +2 -0
  25. data/template/iam-role.rb +11 -0
  26. data/template/iam-user.rb +2 -0
  27. data/template/output-alb.rb +21 -0
  28. data/template/output-elb.rb +4 -0
  29. data/template/parameter-ec2.rb +4 -4
  30. data/test/alb_test.rb +25 -0
  31. data/test/ec2_test.rb +45 -0
  32. data/test/helper_test.rb +21 -0
  33. data/test/template/alb-listener-rule_test.rb +40 -0
  34. data/test/template/alb-listener_test.rb +33 -0
  35. data/test/template/alb-load-balancer_test.rb +72 -0
  36. data/test/template/alb-target-group_test.rb +89 -0
  37. data/test/template/certificate_test.rb +27 -0
  38. data/test/template/ec2-flow-log_test.rb +26 -0
  39. data/test/template/ec2-host_test.rb +23 -0
  40. data/test/template/ec2-spot-fleet_test.rb +173 -0
  41. data/test/template/{elb-loadbalancer_test.rb → elb-load-balancer_test.rb} +1 -1
  42. data/test/template/output-alb_test.rb +105 -0
  43. data/test/template/output-elb_test.rb +61 -0
  44. data/test/template/parameter-ec2_test.rb +38 -9
  45. metadata +36 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e312fcdabe283ed54187861ab3bca524c0514072
4
- data.tar.gz: 52b57de9ea1ad263d9a98aa266a670f8670d9984
3
+ metadata.gz: c0b3009b60eaa96c62f0e6cfcb8b5e93453e19a5
4
+ data.tar.gz: f4cfbdffa75b3855c1aa1f49d7c5f3d032d56331
5
5
  SHA512:
6
- metadata.gz: e7f8b1fd4229e5ed0f9b68cfa5cc741619a254090ebc0b8d1ce9023bb228f34ffb56df4b5cd5383a488479c77e43368e58cabe4fd444c250652b1f4dd2ef7544
7
- data.tar.gz: 1d7dd194fbc6bf98cb05b0a08bbf40e7efdde98fe44c9c18d879df30a46af6c8caecd5942d84d39ef6f61253792c74acc33e37819d0661c31a873386547dd203
6
+ metadata.gz: 8461e8ea61c6a49d1ec819213056ee32a89457da7dff59a1127fe5a8d97351d833084a3242cea845f6b4f507e50085db2650bce8ccb619e176c56b6adb85f97d
7
+ data.tar.gz: 5ede82ac1c09eecb65d379251dd575ccc3ad8da3dd010f8de1c256424a05d53c158d7e9eb4fe53560ab88aba0db5a62c666b8eff63d73e5e2cac23204b4df57a
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kumogata-template (0.0.4)
4
+ kumogata-template (0.0.5)
5
5
  aws-sdk (~> 2.3)
6
- kumogata (= 0.5.8)
6
+ kumogata (= 0.5.10)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- aws-sdk (2.3.8)
12
- aws-sdk-resources (= 2.3.8)
13
- aws-sdk-core (2.3.8)
11
+ aws-sdk (2.5.5)
12
+ aws-sdk-resources (= 2.5.5)
13
+ aws-sdk-core (2.5.5)
14
14
  jmespath (~> 1.0)
15
- aws-sdk-resources (2.3.8)
16
- aws-sdk-core (= 2.3.8)
15
+ aws-sdk-resources (2.5.5)
16
+ aws-sdk-core (= 2.5.5)
17
17
  aws-sdk-v1 (1.66.0)
18
18
  json (~> 1.4)
19
19
  nokogiri (>= 1.4.4)
@@ -23,21 +23,19 @@ GEM
23
23
  execjs
24
24
  coffee-script-source (1.10.0)
25
25
  diffy (3.1.0)
26
- dslh (0.3.7)
26
+ dslh (0.2.7)
27
27
  execjs (2.7.0)
28
28
  hashie (3.4.4)
29
29
  highline (1.7.8)
30
- jmespath (1.2.4)
31
- json_pure (>= 1.8.1)
30
+ jmespath (1.3.1)
32
31
  json (1.8.3)
33
32
  json5 (0.0.1)
34
- json_pure (1.8.3)
35
- kumogata (0.5.8)
33
+ kumogata (0.5.10)
36
34
  aws-sdk-v1
37
35
  coderay
38
36
  coffee-script
39
37
  diffy
40
- dslh (>= 0.2.7)
38
+ dslh (>= 0.2.7, < 0.3)
41
39
  hashie
42
40
  highline
43
41
  json
@@ -48,20 +46,22 @@ GEM
48
46
  therubyracer
49
47
  uuidtools
50
48
  libv8 (3.16.14.15)
51
- mini_portile2 (2.0.0)
49
+ mini_portile2 (2.1.0)
52
50
  minitest (5.9.0)
53
- net-ssh (3.1.1)
54
- nokogiri (1.6.7.2)
55
- mini_portile2 (~> 2.0.0.rc2)
51
+ net-ssh (3.2.0)
52
+ nokogiri (1.6.8)
53
+ mini_portile2 (~> 2.1.0)
54
+ pkg-config (~> 1.1.7)
55
+ pkg-config (1.1.7)
56
56
  rake (11.1.2)
57
57
  ref (2.0.0)
58
- retryable (2.0.3)
58
+ retryable (2.0.4)
59
59
  term-ansicolor (1.3.2)
60
60
  tins (~> 1.0)
61
61
  therubyracer (0.12.2)
62
62
  libv8 (~> 3.16.14.0)
63
63
  ref
64
- tins (1.10.2)
64
+ tins (1.12.0)
65
65
  uuidtools (2.1.5)
66
66
 
67
67
  PLATFORMS
@@ -0,0 +1,99 @@
1
+ #
2
+ # Helper - ALB
3
+ #
4
+ require 'kumogata/template/helper'
5
+
6
+ def _alb_certificates(args)
7
+ certificates = args[:certificates] || []
8
+
9
+ array = []
10
+ certificates.each do |certificate|
11
+ cert = _ref_string("value", { value: certificate }, "certificate")
12
+ next if cert.empty?
13
+
14
+ array << _{
15
+ CertificateArn cert
16
+ }
17
+ end
18
+ array
19
+ end
20
+
21
+ def _alb_actions(args)
22
+ defaults = args[:actions] || []
23
+
24
+ array = []
25
+ defaults.each do |default|
26
+ target = _ref_string("target", default, "target group")
27
+ array << _{
28
+ TargetGroupArn target
29
+ Type "forward"
30
+ }
31
+ end
32
+ array
33
+ end
34
+
35
+ def _alb_conditions(args)
36
+ conditions = args[:conditions] || []
37
+
38
+ array = []
39
+ conditions.each do |condition|
40
+ condition = [ condition ] unless condition.is_a? Array
41
+ array << _{
42
+ Field "path-pattern"
43
+ Values condition
44
+ }
45
+ end
46
+ array
47
+ end
48
+
49
+ def _alb_attributes(args)
50
+ attributes = args[:attributes] || []
51
+
52
+ array = []
53
+ attributes.each do |attribute|
54
+ attribute.each_pair{|key, value|
55
+ array << _{
56
+ Key key
57
+ Value value
58
+ }
59
+ }
60
+ end
61
+ array
62
+ end
63
+
64
+ def _alb_matcher(args)
65
+ args[:matcher] = 200 unless args.key? :matcher
66
+
67
+ http_code = _valid_values(args[:matcher], %w( 200 202 299 ), 200)
68
+ _{
69
+ HttpCode http_code
70
+ }
71
+ end
72
+
73
+ def _alb_health_check(args)
74
+ protocol = _valid_values(args[:protocol] || "", %w( http https ), "http")
75
+ # Return to native hash
76
+ {
77
+ interval: args[:interval] || 30,
78
+ path: args[:path] || "/",
79
+ port: args[:port] || 80,
80
+ protocol: protocol.upcase,
81
+ timeout: args[:timeout] || 5,
82
+ healthy: args[:healthy] || 10,
83
+ unhealthly: args[:unhealthly] || 2,
84
+ }
85
+ end
86
+
87
+ def _alb_targets(args)
88
+ targets = args[:targets] || []
89
+
90
+ array = []
91
+ targets.each do |target|
92
+ id = _ref_string("instance", target, "instance")
93
+ array << _{
94
+ Id id
95
+ Port target[:port] if target.key? :port
96
+ }
97
+ end
98
+ array
99
+ end
@@ -0,0 +1,18 @@
1
+ #
2
+ # Helper - Certificate
3
+ #
4
+ require 'kumogata/template/helper'
5
+
6
+ def _certificate_validations(args)
7
+ validation = args[:validation] || []
8
+ validation << { domain: args[:domain], validation: args[:domain] } if validation.empty?
9
+
10
+ result = []
11
+ validation.each do |val|
12
+ result << _{
13
+ DomainName val[:domain]
14
+ ValidationDomain val[:validation]
15
+ }
16
+ end
17
+ result
18
+ end
@@ -112,10 +112,17 @@ ELASTICACHE_NODE_TYPES =
112
112
  # cache.r3.2xlarge 8 58.2 High
113
113
  # cache.r3.4xlarge 16 118 High
114
114
  # cache.r3.8xlarge 32 237 10 Gigabit
115
+ # cache.m4.large 2 6.42 Moderate
116
+ # cache.m4.xlarge 4 14.28 High
117
+ # cache.m4.2xlarge 8 29.70 High
118
+ # cache.m4.4xlarge 16 60.78 High
119
+ # cache.m4.10xlarge 40 154.64 10 Gigabit
115
120
  "cache.t2.micro", "cache.t2.small", "cache.t2.medium",
116
121
  "cache.m3.medium", "cache.m3.large", "cache.m3.xlarge",
117
122
  "cache.m3.2xlarge", "cache.r3.large", "cache.r3.xlarge",
118
123
  "cache.r3.2xlarge", "cache.r3.4xlarge", "cache.r3.8xlarge",
124
+ "cache.m4.large", "cache.m4.xlarge", "cache.m4.2xlarge",
125
+ "cache.m4.4xlarge", "cache.m4.10xlarge",
119
126
  ]
120
127
  ELASTICACHE_DEFAULT_NODE_TYPE = "cache.t2.medium"
121
128
 
@@ -53,6 +53,12 @@ def _ec2_security_group_ingresses(name, args)
53
53
 
54
54
  rules = []
55
55
  _array(args[name.to_sym]).each do |arg|
56
+ if arg.is_a? Fixnum
57
+ arg = {
58
+ from: arg,
59
+ to: arg,
60
+ }
61
+ end
56
62
  rules << _ec2_security_group_ingress(arg)
57
63
  end
58
64
  rules
@@ -117,3 +117,12 @@ def _ecs_volumes_host(args)
117
117
  SourcePath args[:source_path]
118
118
  }
119
119
  end
120
+
121
+ def _ecs_deployment(args)
122
+ return "" unless args.key? :max or args.key? :min
123
+
124
+ _{
125
+ MaximumPercent args[:max]
126
+ MinimumHealthyPercent args[:min]
127
+ }
128
+ end
@@ -5,7 +5,7 @@ class Kumogata::Client
5
5
  def init(stack_name)
6
6
  begin
7
7
  base_template = ''
8
- File.open(get_template_path("_template"), "r"){|f|
8
+ File.open(get_template_path('_template'), 'r'){|f|
9
9
  base_template = f.read
10
10
  }
11
11
  raise 'initialize template is empty' if base_template.empty?
@@ -17,7 +17,7 @@ class Kumogata::Client
17
17
  return nil if answer.upcase != 'Y'
18
18
  end
19
19
 
20
- File.open(new_template, "w"){|f|
20
+ File.open(new_template, 'w'){|f|
21
21
  template = base_template.gsub('#{NAME}', stack_name)
22
22
  f.write(template)
23
23
  }
@@ -29,9 +29,8 @@ class Kumogata::Client
29
29
  end
30
30
 
31
31
  def define_template_func(scope, path_or_url)
32
- functions = ""
33
-
34
- Dir.glob(File.join(get_template_path, "*.rb")).all? do |file|
32
+ functions = ''
33
+ Dir.glob(File.join(get_template_path, '*.rb')).all? do |file|
35
34
  functions << include_func(path_or_url, file)
36
35
  functions << "\n\n"
37
36
  end
@@ -96,7 +95,7 @@ class Kumogata::Client
96
95
  end
97
96
 
98
97
  def get_template_path(file = nil)
99
- template_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..","..", "template"))
98
+ template_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..','..', 'template'))
100
99
  template_path = File.join(template_path, "#{file}.rb") unless file.nil?
101
100
  template_path
102
101
  end
@@ -92,6 +92,10 @@ def _find_in_map(name, top_level, secondary_level)
92
92
  _{ Fn__FindInMap [ name, top_level, secondary_level ] }
93
93
  end
94
94
 
95
+ def _select(index, list)
96
+ _{ Fn__Select [ index.to_s, list ] }
97
+ end
98
+
95
99
  def _tag(args)
96
100
  key = args[:key].to_s || ""
97
101
  value = args[:value] || ""
@@ -1 +1 @@
1
- KUMOGATA_TEMPLATE_VERSION = '0.0.5'
1
+ KUMOGATA_TEMPLATE_VERSION = '0.0.6'
@@ -1,4 +1,6 @@
1
+ require 'kumogata/template/alb'
1
2
  require 'kumogata/template/autoscaling'
3
+ require 'kumogata/template/certificate'
2
4
  require 'kumogata/template/cloudwatch'
3
5
  require 'kumogata/template/codedeploy'
4
6
  require 'kumogata/template/const'
@@ -0,0 +1,22 @@
1
+ #
2
+ # ALB(ElasticLoadBalancingV2) ListenerRule resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-listenerrule.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/alb'
7
+
8
+ name = _resource_name(args[:name], "load balancer listener rule")
9
+ actions = _alb_actions(args)
10
+ conditions = _alb_conditions(args)
11
+ listener = _ref_string("listener", args, "load balancer listener")
12
+ priority = args[:priority] || 1
13
+
14
+ _(name) do
15
+ Type "AWS::ElasticLoadBalancingV2::ListenerRule"
16
+ Properties do
17
+ Actions actions
18
+ Conditions conditions
19
+ ListenerArn listener
20
+ Priority priority
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # ALB(ElasticLoadBalancingV2) Listener resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-listener.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/alb'
7
+
8
+ name = _resource_name(args[:name], "load balancer listener")
9
+ certificates = _alb_certificates(args)
10
+ defaults = _alb_actions(args)
11
+ lb = _ref_string("lb", args, "load balancer")
12
+ port = args[:port] || 80
13
+ protocol = _valid_values("protocol", %w( http https ), "http")
14
+ ssl = args[:ssl] || ""
15
+
16
+ _(name) do
17
+ Type "AWS::ElasticLoadBalancingV2::Listener"
18
+ Properties do
19
+ Certificates certificates unless certificates.empty?
20
+ DefaultActions defaults
21
+ LoadBalancerArn lb
22
+ Port port
23
+ Protocol protocol.upcase
24
+ SslPolicy ssl unless ssl.empty?
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # ALB(ElasticLoadBalancingV2) LoadBalancer resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-loadbalancer.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/alb'
7
+
8
+ name = _resource_name(args[:name], "load balancer")
9
+ lb_attributes = _alb_attributes(args)
10
+ lb_name = _ref_name("lb_name", args)
11
+ lb_name = args[:name] if lb_name.empty?
12
+ scheme = _valid_values("scheme", %w( internal internal-facing ), "")
13
+ security_groups = _ref_array("security_groups", args, "security group")
14
+ subnets = _ref_array("subnets", args, "subnet")
15
+ tags = _tags(args)
16
+
17
+ _(name) do
18
+ Type "AWS::ElasticLoadBalancingV2::LoadBalancer"
19
+ Properties do
20
+ LoadBalancerAttributes lb_attributes
21
+ Name lb_name
22
+ Scheme scheme unless scheme.empty?
23
+ SecurityGroups security_groups
24
+ Subnets subnets unless subnets.empty?
25
+ Tags tags
26
+ end
27
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # ALB(ElasticLoadBalancingV2) TargetGroup resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/alb'
7
+
8
+ name = _resource_name(args[:name], "target group")
9
+ health_check = _alb_health_check(args[:health_check] || {})
10
+ matcher = _alb_matcher(args)
11
+ target_name = _ref_name("target_name", args)
12
+ target_name = args[:name] if target_name.empty?
13
+ attributes = _alb_attributes(args)
14
+ port = args[:port] || 80
15
+ protocol = _valid_values("protocol", %w( http https ), "http")
16
+ tags = _tags(args)
17
+ targets = _alb_targets(args)
18
+ vpc = _ref_string("vpc", args, "vpc")
19
+
20
+ _(name) do
21
+ Type "AWS::ElasticLoadBalancingV2::TargetGroup"
22
+ Properties do
23
+ HealthCheckIntervalSeconds health_check[:interval]
24
+ HealthCheckPath health_check[:path]
25
+ HealthCheckPort health_check[:port]
26
+ HealthCheckProtocol health_check[:protocol]
27
+ HealthCheckTimeoutSeconds health_check[:timeout]
28
+ HealthyThresholdCount health_check[:healthy]
29
+ Matcher matcher
30
+ Name target_name
31
+ Port port
32
+ Protocol protocol.upcase
33
+ Tags tags
34
+ TargetGroupAttributes attributes
35
+ Targets targets
36
+ UnhealthyThresholdCount health_check[:unhealthly]
37
+ VpcId vpc
38
+ end
39
+ end
@@ -21,6 +21,7 @@ max = min if max < min
21
21
  notifications = (args[:notifications] || []).collect{|v| _autoscaling_notification(v) }
22
22
  placement = args[:placement] || ""
23
23
  tags = _autoscaling_tags(args)
24
+ target_groups = args[:target_groups] || []
24
25
  terminations = _autoscaling_terminations(args)
25
26
  vpc_zones = _ref_array("vpc_zones", args, "subnet")
26
27
 
@@ -41,6 +42,7 @@ _(name) do
41
42
  NotificationConfigurations notifications
42
43
  PlacementGroup placement unless placement.empty?
43
44
  Tags tags
45
+ TargetGroupARNs target_groups unless target_groups.empty?
44
46
  TerminationPolicies terminations unless terminations.empty?
45
47
  VPCZoneIdentifier vpc_zones unless vpc_zones.empty?
46
48
  end
@@ -0,0 +1,20 @@
1
+ #
2
+ # CertificateManager Certificate resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-certificatemanager-certificate.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/certificate'
7
+
8
+ name = _resource_name(args[:name], "certificate")
9
+ domain = args[:domain]
10
+ validation = _certificate_validations(args)
11
+ subject = args[:subject] || ""
12
+
13
+ _(name) do
14
+ Type "AWS::CertificateManager::Certificate"
15
+ Properties do
16
+ DomainName domain
17
+ DomainValidationOptions validation
18
+ SubjectAlternativeNames subject unless subject.empty?
19
+ end
20
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # EC2 FlowLog resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-flowlog.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/ec2'
7
+
8
+ name = _resource_name(args[:name], "flow log")
9
+ deliver = _ref_attr_string("deliver", "Arn", args, "role")
10
+ log = args[:log] || args[:name]
11
+ resource_type_value = _valid_values(args[:type], %w( vpc subnet nic ), "vpc")
12
+ resource_id =
13
+ case resource_type_value.downcase
14
+ when "vpc"
15
+ _ref_string("id", args, "vpc")
16
+ when "subnet"
17
+ _ref_string("id", args, "subnet")
18
+ when "nic"
19
+ _ref_string("id", args, "network interface")
20
+ end
21
+ resource_type =
22
+ case resource_type_value.downcase
23
+ when "vpc"
24
+ "VPC"
25
+ when "subnet"
26
+ "Subnet"
27
+ when "nic"
28
+ "NetworkInterface"
29
+ end
30
+ traffic = _valid_values(args[:traffic], %w( accept reject all ), "all")
31
+
32
+ _(name) do
33
+ Type "AWS::EC2::FlowLog"
34
+ Properties do
35
+ DeliverLogsPermissionArn deliver unless deliver.empty?
36
+ LogGroupName log
37
+ ResourceId resource_id
38
+ ResourceType resource_type
39
+ TrafficType traffic.upcase
40
+ end
41
+ end
@@ -0,0 +1,21 @@
1
+ #
2
+ # EC2 Host resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-host.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/ec2'
7
+
8
+ name = _resource_name(args[:name], "host")
9
+ auto = _valid_values(args[:auto], %w( on off ), "")
10
+ az = _availability_zone(args)
11
+ instance_type = _ref_string("instance_type", args, "instance type")
12
+ instance_type = EMR_DEFAULT_INSTANCE_TYPE if instance_type.empty?
13
+
14
+ _(name) do
15
+ Type "AWS::EC2::Host"
16
+ Properties do
17
+ AutoPlacement auto unless auto.empty?
18
+ AvailabilityZone az
19
+ InstanceType instance_type
20
+ end
21
+ end
@@ -7,9 +7,11 @@ require 'kumogata/template/ec2'
7
7
 
8
8
  name = _resource_name(args[:name], "instance")
9
9
  instance_type = _ref_string("instance_type", args, "instance type")
10
+ affinity = _valid_values(args[:affinity], %w( host default ), "")
10
11
  az = _availability_zone(args)
11
12
  block_device = (args[:block_device] || []).collect{|v| _ec2_block_device(v) }
12
13
  disable_termination = _bool("disable_termination", args, false)
14
+ host_id = args[:host_id] || ""
13
15
  iam_instance = _ref_string("iam_instance", args, "iam instance profile")
14
16
  image =_ec2_image(instance_type, args)
15
17
  instance_initiated = args[:instance_initiated] || "stop"
@@ -32,11 +34,13 @@ volumes = args[:volumes] || ""
32
34
  _(name) do
33
35
  Type "AWS::EC2::Instance"
34
36
  Properties do
37
+ Affinity affinity unless affinity.empty?
35
38
  AvailabilityZone az unless az.empty?
36
39
  BlockDeviceMappings block_device
37
40
  DisableApiTermination disable_termination
38
41
  #EbsOptimized
39
- IamInstanceProfile iam_instance
42
+ HostId host_id unless affinity.empty? and host_id.empty?
43
+ IamInstanceProfile iam_instance unless iam_instance.empty?
40
44
  ImageId image
41
45
  InstanceInitiatedShutdownBehavior instance_initiated
42
46
  InstanceType instance_type
@@ -0,0 +1,16 @@
1
+ #
2
+ # EC2 Spot Fleet resource
3
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+ require 'kumogata/template/ec2'
7
+
8
+ name = _resource_name(args[:name], "spot fleet")
9
+ data = _ec2_spot_fleet_request(args)
10
+
11
+ _(name) do
12
+ Type "AWS::EC2::SpotFleet"
13
+ Properties do
14
+ SpotFleetRequestConfigData data
15
+ end
16
+ end
@@ -7,6 +7,7 @@ require 'kumogata/template/ecs'
7
7
 
8
8
  name = _resource_name(args[:name], "ecs service")
9
9
  cluster = _ref_string("cluster", args, "ecs cluster")
10
+ deployment = _ecs_deployment(args)
10
11
  desired = _ref_string("desired_count", args, "ecs desired count")
11
12
  load_balancers = _ecs_load_balancers(args)
12
13
  role = args[:role] || ""
@@ -16,6 +17,7 @@ _(name) do
16
17
  Type "AWS::ECS::Service"
17
18
  Properties do
18
19
  Cluster cluster
20
+ DeploymentConfiguration deployment unless deployment.empty?
19
21
  DesiredCount desired
20
22
  LoadBalancers load_balancers unless load_balancers.empty?
21
23
  Role role unless role.empty?
@@ -1,5 +1,5 @@
1
1
  #
2
- # ElasticLoadBalancing LoadBalancer resource
2
+ # ELB(ElasticLoadBalancing) LoadBalancer resource
3
3
  # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb.html
4
4
  #
5
5
  require 'kumogata/template/helper'
@@ -6,6 +6,7 @@ require 'kumogata/template/helper'
6
6
  require 'kumogata/template/iam'
7
7
 
8
8
  name = _resource_name(args[:name], "group")
9
+ group = args[:group] || ""
9
10
  managed_policies =
10
11
  if args.key? :managed_policies
11
12
  _iam_managed_policies(args)
@@ -18,6 +19,7 @@ policies = _iam_policies("policies", args)
18
19
  _(name) do
19
20
  Type "AWS::IAM::Group"
20
21
  Properties do
22
+ GroupName group_name unless group.empty?
21
23
  ManagedPolicyArns managed_policies unless managed_policies.empty?
22
24
  Path path
23
25
  Policies policies unless policies.empty?
data/template/iam-role.rb CHANGED
@@ -7,7 +7,15 @@ require 'kumogata/template/iam'
7
7
 
8
8
  name = _resource_name(args[:name], "role")
9
9
  policy = _iam_assume_role_policy_document(args)
10
+ managed_policies =
11
+ if args.key? :managed_policies
12
+ _iam_managed_policies(args)
13
+ else
14
+ []
15
+ end
10
16
  path = args[:path] || "/"
17
+ policies = _iam_policies("policies", args)
18
+ role = args[:role] || ""
11
19
 
12
20
  _(name) do
13
21
  Type "AWS::IAM::Role"
@@ -16,6 +24,9 @@ _(name) do
16
24
  Version "2012-10-17"
17
25
  Statement policy
18
26
  end
27
+ ManagedPolicyArns managed_policies unless managed_policies.empty?
19
28
  Path path
29
+ Policies policies unless policies.empty?
30
+ RoleName role unless role.empty?
20
31
  end
21
32
  end
data/template/iam-user.rb CHANGED
@@ -21,6 +21,7 @@ managed_policies =
21
21
  end
22
22
  path = args[:path] || "/"
23
23
  policies = _iam_policies("policies", args)
24
+ user = args[:user] || ""
24
25
 
25
26
  _(name) do
26
27
  Type "AWS::IAM::User"
@@ -30,5 +31,6 @@ _(name) do
30
31
  ManagedPolicyArns managed_policies unless managed_policies.empty?
31
32
  Path path
32
33
  Policies policies unless policies.empty?
34
+ UserName user unless user.empty?
33
35
  end
34
36
  end