kumogata-template 0.0.33 → 0.0.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +30 -49
  4. data/kumogata-template.gemspec +1 -1
  5. data/lib/kumogata/template/ec2.rb +16 -18
  6. data/lib/kumogata/template/helper.rb +14 -36
  7. data/lib/kumogata/template/iam.rb +2 -0
  8. data/lib/kumogata/template/s3.rb +15 -0
  9. data/lib/kumogata/template/sns.rb +7 -2
  10. data/lib/kumogata/template/version.rb +1 -1
  11. data/template/ec2-customer-gateway.rb +21 -0
  12. data/template/ec2-dhcp-options.rb +25 -0
  13. data/template/ec2-egress-only-internet-gateway.rb +15 -0
  14. data/template/ec2-instance.rb +2 -2
  15. data/template/ec2-network-interface-attachment.rb +22 -0
  16. data/template/ec2-network-interface.rb +32 -0
  17. data/template/ec2-placement-group.rb +17 -0
  18. data/template/ec2-security-group-egress.rb +15 -0
  19. data/template/ec2-security-group-ingress.rb +19 -0
  20. data/template/ec2-security-group.rb +4 -4
  21. data/template/ec2-subnet-cidr-block.rb +17 -0
  22. data/template/ec2-vpc-cidr-block.rb +17 -0
  23. data/template/ec2-vpc-dhcp-options-association.rb +17 -0
  24. data/template/ec2-vpc-peering-connection.rb +23 -0
  25. data/template/ec2-vpn-connection-route.rb +17 -0
  26. data/template/ec2-vpn-connection.rb +23 -0
  27. data/template/ec2-vpn-gateway-route-propagation.rb +17 -0
  28. data/template/ec2-vpn-gateway.rb +17 -0
  29. data/template/ecs-service.rb +2 -2
  30. data/template/iam-group.rb +2 -2
  31. data/template/iam-instance-profile.rb +2 -2
  32. data/template/iam-role.rb +2 -2
  33. data/template/iam-user.rb +2 -2
  34. data/template/output-access-key.rb +2 -2
  35. data/template/{output-iam-instance-profile.rb → output-instance-profile.rb} +1 -1
  36. data/template/output-network-interface.rb +14 -0
  37. data/template/{output-iam-role.rb → output-role.rb} +1 -1
  38. data/template/{output-ec2-subnet.rb → output-subnet.rb} +1 -1
  39. data/template/rds-db-instance.rb +5 -1
  40. data/template/s3-bucket.rb +1 -2
  41. data/template/sns-topic.rb +2 -2
  42. data/test/ec2_test.rb +17 -18
  43. data/test/helper_test.rb +4 -2
  44. data/test/sns_test.rb +16 -0
  45. data/test/template/ec2-customer-gateway_tet.rb +55 -0
  46. data/test/template/ec2-dhcp-options_test.rb +49 -0
  47. data/test/template/ec2-egress-only-internet-gateway_test.rb +23 -0
  48. data/test/template/ec2-instance_test.rb +1 -1
  49. data/test/template/ec2-network-interface-attachment_tet.rb +28 -0
  50. data/test/template/ec2-network-interface_test.rb +52 -0
  51. data/test/template/ec2-placement-group_test.rb +21 -0
  52. data/test/template/ec2-security-group-egress_test.rb +25 -0
  53. data/test/template/ec2-security-group-ingress_test.rb +25 -0
  54. data/test/template/ec2-security-group_test.rb +1 -0
  55. data/test/template/ec2-subnet-cidr-block_test.rb +26 -0
  56. data/test/template/ec2-vpc-cidr-block_test.rb +24 -0
  57. data/test/template/ec2-vpc-dhcp-options-association_test.rb +26 -0
  58. data/test/template/ec2-vpc-peering-connection_test.rb +54 -0
  59. data/test/template/ec2-vpn-connection-route_test.rb +26 -0
  60. data/test/template/ec2-vpn-connection_test.rb +56 -0
  61. data/test/template/ec2-vpn-gateway-route-propagation_test.rb +28 -0
  62. data/test/template/ec2-vpn-gateway_test.rb +49 -0
  63. data/test/template/ecs-service_test.rb +1 -0
  64. data/test/template/iam-instance-profile_test.rb +4 -3
  65. data/test/template/iam-user_test.rb +54 -0
  66. data/test/template/output-access-key_test.rb +2 -2
  67. data/test/template/{output-iam-instance-profile_test.rb → output-instance-profile_test.rb} +2 -2
  68. data/test/template/output-network-interface_test.rb +39 -0
  69. data/test/template/{output-iam-role_test.rb → output-role_test.rb} +2 -2
  70. data/test/template/{output-ec2-subet_test.rb → output-subet_test.rb} +2 -2
  71. data/test/template/rds-db-instance_test.rb +5 -5
  72. data/test/template/s3-bucket_test.rb +60 -0
  73. metadata +66 -16
  74. data/Gemfile.lock +0 -51
@@ -0,0 +1,17 @@
1
+ #
2
+ # EC2 VPC DHCP Options Association resource
3
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpc-dhcp-options-assoc.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+
7
+ name = _resource_name(args[:name], "vpc dhcp options association")
8
+ dhcp = _ref_string("dhcp", args, "dhcp options")
9
+ vpc = _ref_string("vpc", args, "vpc")
10
+
11
+ _(name) do
12
+ Type "AWS::EC2::VPCDHCPOptionsAssociation"
13
+ Properties do
14
+ DhcpOptionsId dhcp
15
+ VpcId vpc
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ #
2
+ # EC2 VPC Peerning Connection resource
3
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcpeeringconnection.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+
7
+ name = _resource_name(args[:name], "vpc peering connection")
8
+ peer_vpc = _ref_string("peer_vpc", args, "vpc")
9
+ tags = _tags(args)
10
+ vpc = _ref_string("vpc", args, "vpc")
11
+ peer_owner = _ref_string("peer_owner", args, "peer owner")
12
+ peer_role = _ref_attr_string("peer_role", "Arn", args, "role")
13
+
14
+ _(name) do
15
+ Type "AWS::EC2::VPCPeeringConnection"
16
+ Properties do
17
+ PeerVpcId peer_vpc
18
+ Tags tags
19
+ VpcId vpc
20
+ PeerOwnerId peer_owner unless peer_owner.empty?
21
+ PeerRoleArn peer_role unless peer_role.empty?
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ #
2
+ # EC2 VPN Connection Route resource
3
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpn-connection-route.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+
7
+ name = _resource_name(args[:name], "vpn connection route")
8
+ cidr = _ref_string("cidr", args, "cidr")
9
+ vpn = _ref_string("vpn", args, "vpn connection")
10
+
11
+ _(name) do
12
+ Type "AWS::EC2::VPNConnectionRoute"
13
+ Properties do
14
+ DestinationCidrBlock cidr
15
+ VpnConnectionId vpn
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ #
2
+ # EC2 VPN Connection resource
3
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpn-connection.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+
7
+ name = _resource_name(args[:name], "vpn connection")
8
+ type = _ref_string("type", args)
9
+ customer = _ref_string("customer", args, "customer gateway")
10
+ static = true
11
+ tags = _tags(args)
12
+ vpn = _ref_string("vpn", args, "vpn gateway")
13
+
14
+ _(name) do
15
+ Type "AWS::EC2::VPNConnection"
16
+ Properties do
17
+ Type type
18
+ CustomerGatewayId customer
19
+ StaticRoutesOnly static
20
+ Tags tags
21
+ VpnGatewayId vpn
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ #
2
+ # EC2 VPN Gateway Route Propagation resource
3
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpn-gatewayrouteprop.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+
7
+ name = _resource_name(args[:name], "vpn gateway route propagation")
8
+ routes = _ref_array("routes", args, "route table")
9
+ vpn = _ref_string("vpn", args, "vpn gateway")
10
+
11
+ _(name) do
12
+ Type "AWS::EC2::VPNGatewayRoutePropagation"
13
+ Properties do
14
+ RouteTableIds routes
15
+ VpnGatewayId vpn
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ #
2
+ # EC2 VPN Gateway resource
3
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpn-gateway.html
4
+ #
5
+ require 'kumogata/template/helper'
6
+
7
+ name = _resource_name(args[:name], "vpn gateway")
8
+ type = _ref_string("type", args)
9
+ tags = _tags(args)
10
+
11
+ _(name) do
12
+ Type "AWS::EC2::VPNGateway"
13
+ Properties do
14
+ Type type
15
+ Tags tags
16
+ end
17
+ end
@@ -12,7 +12,7 @@ desired = _ref_string("desired_count", args, "ecs desired count")
12
12
  load_balancers = _ecs_load_balancers(args)
13
13
  placement = _ecs_placement_service(args)
14
14
  role = args[:role] || ""
15
- service_name = _real_name(args[:service_name] || "")
15
+ service_name = _real_name("service", args)
16
16
  task = _ref_string("task", args, "ecs task definition")
17
17
 
18
18
  _(name) do
@@ -24,7 +24,7 @@ _(name) do
24
24
  LoadBalancers load_balancers unless load_balancers.empty?
25
25
  PlacementConstraints placement unless placement.empty?
26
26
  Role role unless role.empty?
27
- ServiceName service_name unless service_name.empty?
27
+ ServiceName service_name if service_name
28
28
  TaskDefinition task
29
29
  end
30
30
  end
@@ -6,7 +6,7 @@ require 'kumogata/template/helper'
6
6
  require 'kumogata/template/iam'
7
7
 
8
8
  name = _resource_name(args[:name], "group")
9
- group = _real_name(args[:group] || args[:name])
9
+ group_name = _real_name("group", args)
10
10
  managed_policies =
11
11
  if args.key? :managed_policies
12
12
  _iam_managed_policies(args)
@@ -19,7 +19,7 @@ policies = _iam_policies("policies", args)
19
19
  _(name) do
20
20
  Type "AWS::IAM::Group"
21
21
  Properties do
22
- GroupName group
22
+ GroupName group_name if group_name
23
23
  ManagedPolicyArns managed_policies unless managed_policies.empty?
24
24
  Path path
25
25
  Policies policies unless policies.empty?
@@ -7,13 +7,13 @@ require 'kumogata/template/helper'
7
7
  name = _resource_name(args[:name], "instance profile")
8
8
  path = args[:path] || "/"
9
9
  roles = _ref_array("roles", args, "role")
10
- profile_name = _real_name(args[:profile_name] || "")
10
+ profile_name = _real_name("profile", args)
11
11
 
12
12
  _(name) do
13
13
  Type "AWS::IAM::InstanceProfile"
14
14
  Properties do
15
15
  Path path
16
16
  Roles roles
17
- InstanceProfileName profile_name unless profile_name.empty?
17
+ InstanceProfileName profile_name if profile_name
18
18
  end
19
19
  end
data/template/iam-role.rb CHANGED
@@ -15,7 +15,7 @@ managed_policies =
15
15
  end
16
16
  path = args[:path] || "/"
17
17
  policies = _iam_policies("policies", args)
18
- role = _real_name(args[:role] || args[:name])
18
+ role_name = _real_name("role", args)
19
19
 
20
20
  _(name) do
21
21
  Type "AWS::IAM::Role"
@@ -27,6 +27,6 @@ _(name) do
27
27
  ManagedPolicyArns managed_policies unless managed_policies.empty?
28
28
  Path path
29
29
  Policies policies unless policies.empty?
30
- RoleName role
30
+ RoleName role_name if role_name
31
31
  end
32
32
  end
data/template/iam-user.rb CHANGED
@@ -21,7 +21,7 @@ managed_policies =
21
21
  end
22
22
  path = args[:path] || "/"
23
23
  policies = _iam_policies("policies", args)
24
- user = _real_name(args[:user] || args[:name])
24
+ user = _real_name("user", args)
25
25
 
26
26
  _(name) do
27
27
  Type "AWS::IAM::User"
@@ -31,6 +31,6 @@ _(name) do
31
31
  ManagedPolicyArns managed_policies unless managed_policies.empty?
32
32
  Path path
33
33
  Policies policies unless policies.empty?
34
- UserName user
34
+ UserName user if user
35
35
  end
36
36
  end
@@ -4,8 +4,8 @@
4
4
  require 'kumogata/template/helper'
5
5
 
6
6
  _output "#{args[:name]} access key",
7
- ref_value: args[:name],
7
+ ref_value: "#{args[:name]} access key",
8
8
  export: _export_string(args, "access key")
9
9
  _output "#{args[:name]} secret access key",
10
- ref_value: [ args[:name], "SecretAccessKey" ],
10
+ ref_value: [ "#{args[:name]} access key", "SecretAccessKey" ],
11
11
  export: _export_string(args, "secret access key")
@@ -1,5 +1,5 @@
1
1
  #
2
- # Output IAM instance profile
2
+ # Output instance profile
3
3
  #
4
4
  require 'kumogata/template/helper'
5
5
 
@@ -0,0 +1,14 @@
1
+ #
2
+ # Output network interface
3
+ #
4
+ require 'kumogata/template/helper'
5
+
6
+ _output "#{args[:name]} network interface",
7
+ ref_value: "#{args[:name]} network interface",
8
+ export: _export_string(args, "network interface")
9
+ _output "#{args[:name]} network interface private ip",
10
+ ref_value: [ "#{args[:name]} network interface", "PrimaryPrivateIpAddress" ],
11
+ export: _export_string(args, "network interface private ip")
12
+ _output "#{args[:name]} network interface secondary ips",
13
+ ref_value: [ "#{args[:name]} network interface", "SecondaryPrivateIpAddresses" ],
14
+ export: _export_string(args, "network interface secondary ips")
@@ -1,5 +1,5 @@
1
1
  #
2
- # Output IAM role
2
+ # Output role
3
3
  #
4
4
  require 'kumogata/template/helper'
5
5
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Output ec2 subnet
2
+ # Output subnet
3
3
  #
4
4
  require 'kumogata/template/helper'
5
5
 
@@ -44,9 +44,11 @@ iops =
44
44
  ""
45
45
  end
46
46
  kms = _ref_attr_string("kms", "Arn", args)
47
- license = _valid_values(args[:license], %w( license-included bring-your-own-license general-public-license ), "general-public-license")
47
+ license = _valid_values(args[:license], %w( license-included bring-your-own-license general-public-license ))
48
48
  user_name = _ref_string("user_name", args, "db master user name")
49
49
  user_password = _ref_string("user_password", args, "db master user password")
50
+ monitoring_interval = _ref_number("monitoring_interval", args, "db monitoring interval")
51
+ monitoring_role_arn = _ref_string("monitoring_role_arn", args, "db monitoring role arn")
50
52
  multi_az = _bool("multi_az", args, false)
51
53
  option = _ref_string("option", args, "db option group")
52
54
  port = _ref_string_default("port", args, "db port", PORT[engine.to_sym])
@@ -154,6 +156,8 @@ _(name) do
154
156
  LicenseModel license unless _empty? license
155
157
  MasterUsername user_name unless _empty? user_name
156
158
  MasterUserPassword user_password unless _empty? user_password
159
+ MonitoringInterval monitoring_interval unless _empty? monitoring_interval
160
+ MonitoringRoleArn monitoring_role_arn unless _empty? monitoring_role_arn
157
161
  MultiAZ multi_az unless _empty? multi_az
158
162
  OptionGroupName option unless _empty? option
159
163
  Port port unless _empty? port
@@ -21,8 +21,7 @@ replication = _s3_replication(args)
21
21
  tags = _tags(args)
22
22
  versioning = _s3_versioning(args)
23
23
  website = _s3_website(args)
24
- deletion_policy = _valid_values(args[:deletion_policy],
25
- %w( Delete Retain Snapshot ), "Retain")
24
+ deletion_policy = _s3_to_deletion_policy(args[:deletion_policy])
26
25
 
27
26
  _(name) do
28
27
  Type "AWS::S3::Bucket"
@@ -6,9 +6,9 @@ require 'kumogata/template/helper'
6
6
  require 'kumogata/template/sns'
7
7
 
8
8
  name = _resource_name(args[:name], "topic")
9
- display = args[:display] || ""
9
+ display = _real_name("display", args)
10
10
  subscription = _sns_subscription_list(args)
11
- topic = _ref_name("topic", args)
11
+ topic = _real_name("topic", args)
12
12
 
13
13
  _(name) do
14
14
  Type "AWS::SNS::Topic"
data/test/ec2_test.rb CHANGED
@@ -110,10 +110,10 @@ Test _ec2_tags(name: "test", tags_append: { ref_test: "test" })
110
110
  assert_equal exp_template.chomp, act_template
111
111
  end
112
112
 
113
- def test_ec2_security_group_egresses
113
+ def test_ec2_security_group_egress_rules
114
114
  template = <<-EOS
115
- args = { egress: [ to: 80, group: "test" ] }
116
- Test _ec2_security_group_egresses("egress", args)
115
+ args = { egress: [ to: 80 ] }
116
+ Test _ec2_security_group_egress_rules("egress", args)
117
117
  EOS
118
118
  act_template = run_client_as_json(template)
119
119
  exp_template = <<-EOS
@@ -122,7 +122,6 @@ Test _ec2_security_group_egresses("egress", args)
122
122
  {
123
123
  "CidrIp": "0.0.0.0/0",
124
124
  "FromPort": "80",
125
- "GroupId": "test",
126
125
  "IpProtocol": "tcp",
127
126
  "ToPort": "80"
128
127
  }
@@ -132,8 +131,8 @@ Test _ec2_security_group_egresses("egress", args)
132
131
  assert_equal exp_template.chomp, act_template
133
132
 
134
133
  template = <<-EOS
135
- args = { egress: [ to: 80, group: "test" ] }
136
- Test _ec2_security_group_egresses("egress", args)
134
+ args = { egress: [ to: 80 ] }
135
+ Test _ec2_security_group_egress_rules("egress", args)
137
136
  EOS
138
137
  act_template = run_client_as_json(template)
139
138
  exp_template = <<-EOS
@@ -142,7 +141,6 @@ Test _ec2_security_group_egresses("egress", args)
142
141
  {
143
142
  "CidrIp": "0.0.0.0/0",
144
143
  "FromPort": "80",
145
- "GroupId": "test",
146
144
  "IpProtocol": "tcp",
147
145
  "ToPort": "80"
148
146
  }
@@ -152,9 +150,9 @@ Test _ec2_security_group_egresses("egress", args)
152
150
  assert_equal exp_template.chomp, act_template
153
151
  end
154
152
 
155
- def test_ec2_security_group_eggress
153
+ def test_ec2_security_group_egress_rule
156
154
  template = <<-EOS
157
- Test _ec2_security_group_egress(to: 80, group: "test")
155
+ Test _ec2_security_group_egress_rule(to: 80)
158
156
  EOS
159
157
  act_template = run_client_as_json(template)
160
158
  exp_template = <<-EOS
@@ -162,7 +160,6 @@ Test _ec2_security_group_egress(to: 80, group: "test")
162
160
  "Test": {
163
161
  "CidrIp": "0.0.0.0/0",
164
162
  "FromPort": "80",
165
- "GroupId": "test",
166
163
  "IpProtocol": "tcp",
167
164
  "ToPort": "80"
168
165
  }
@@ -171,10 +168,10 @@ Test _ec2_security_group_egress(to: 80, group: "test")
171
168
  assert_equal exp_template.chomp, act_template
172
169
  end
173
170
 
174
- def test_ec2_security_group_ingresses
171
+ def test_ec2_security_group_ingress_rules
175
172
  template = <<-EOS
176
173
  args = { ingress: [ from: 80 ] }
177
- Test _ec2_security_group_ingresses("ingress", args)
174
+ Test _ec2_security_group_ingress_rules("ingress", args)
178
175
  EOS
179
176
  act_template = run_client_as_json(template)
180
177
  exp_template = <<-EOS
@@ -193,7 +190,7 @@ Test _ec2_security_group_ingresses("ingress", args)
193
190
 
194
191
  template = <<-EOS
195
192
  args = { ingress: [ 22, 80 ] }
196
- Test _ec2_security_group_ingresses("ingress", args)
193
+ Test _ec2_security_group_ingress_rules("ingress", args)
197
194
  EOS
198
195
  act_template = run_client_as_json(template)
199
196
  exp_template = <<-EOS
@@ -217,9 +214,9 @@ Test _ec2_security_group_ingresses("ingress", args)
217
214
  assert_equal exp_template.chomp, act_template
218
215
  end
219
216
 
220
- def test_ec2_security_group_ingress
217
+ def test_ec2_security_group_ingress_rule
221
218
  template = <<-EOS
222
- Test _ec2_security_group_ingress(from: 80)
219
+ Test _ec2_security_group_ingress_rule(from: 80)
223
220
  EOS
224
221
  act_template = run_client_as_json(template)
225
222
  exp_template = <<-EOS
@@ -257,9 +254,9 @@ Test _ec2_block_device(ref_size: "test")
257
254
  assert_equal exp_template.chomp, act_template
258
255
  end
259
256
 
260
- def test_ec2_network_interface
257
+ def test_ec2_network_interface_embedded
261
258
  template = <<-EOS
262
- Test _ec2_network_interface(ref_subnet_id: "test")
259
+ Test _ec2_network_interface_embedded(ref_subnet: "test")
263
260
  EOS
264
261
  act_template = run_client_as_json(template)
265
262
  exp_template = <<-EOS
@@ -268,7 +265,9 @@ Test _ec2_network_interface(ref_subnet_id: "test")
268
265
  "AssociatePublicIpAddress": "true",
269
266
  "DeleteOnTermination": "true",
270
267
  "DeviceIndex": "0",
271
- "SubnetId": ""
268
+ "SubnetId": {
269
+ "Ref": "TestSubnet"
270
+ }
272
271
  }
273
272
  }
274
273
  EOS
data/test/helper_test.rb CHANGED
@@ -83,7 +83,9 @@ EOS
83
83
  end
84
84
 
85
85
  def test_real_name
86
- assert_equal _real_name("test test"), "test-test"
86
+ assert_equal _real_name("test", { name: "test" }), "test"
87
+ assert_equal _real_name("test", { name: "test", test: "test test" }), "test-test"
88
+ assert_equal _real_name("test", { name: "test", test: false }), false
87
89
  end
88
90
 
89
91
  def test_ref_key
@@ -602,7 +604,7 @@ Test _base64_shell("test shell")
602
604
  exp_template = <<-EOS
603
605
  {
604
606
  "Test": {
605
- "Fn::Base64": "#!/bin/bash\\ntest shell"
607
+ "Fn::Base64": "#!/bin/bash\\ntest shell\\n"
606
608
  }
607
609
  }
608
610
  EOS
data/test/sns_test.rb CHANGED
@@ -3,6 +3,22 @@ require 'kumogata/template/sns'
3
3
 
4
4
  class SnsTest < Minitest::Test
5
5
  def test_sns_subscription
6
+ template = <<-EOS
7
+ Test _sns_subscription_list(subscription: [ "test" ])
8
+ EOS
9
+ act_template = run_client_as_json(template)
10
+ exp_template = <<-EOS
11
+ {
12
+ "Test": [
13
+ {
14
+ "Endpoint": "test",
15
+ "Protocol": "email"
16
+ }
17
+ ]
18
+ }
19
+ EOS
20
+ assert_equal exp_template.chomp, act_template
21
+
6
22
  template = <<-EOS
7
23
  Test _sns_subscription_list(subscription: [ { protocol: "lambda", endpoint: "test" } ])
8
24
  EOS
@@ -0,0 +1,55 @@
1
+ require 'abstract_unit'
2
+
3
+ class Ec2CustomerGatewayTest < Minitest::Test
4
+ def test_normal
5
+ template = <<-EOS
6
+ _ec2_customer_gateway "test", ref_bgp: "test", ref_ip: "test", type: "test"
7
+ EOS
8
+ act_template = run_client_as_json(template)
9
+ exp_template = <<-EOS
10
+ {
11
+ "TestCustomerGateway": {
12
+ "Type": "AWS::EC2::CustomerGateway",
13
+ "Properties": {
14
+ "BgpAsn": {
15
+ "Ref": "TestBgp"
16
+ },
17
+ "IpAddress": {
18
+ "Ref": "TestIp"
19
+ },
20
+ "Tags": [
21
+ {
22
+ "Key": "Name",
23
+ "Value": {
24
+ "Fn::Join": [
25
+ "-",
26
+ [
27
+ {
28
+ "Ref": "Service"
29
+ },
30
+ "test"
31
+ ]
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "Key": "Service",
37
+ "Value": {
38
+ "Ref": "Service"
39
+ }
40
+ },
41
+ {
42
+ "Key": "Version",
43
+ "Value": {
44
+ "Ref": "Version"
45
+ }
46
+ }
47
+ ],
48
+ "Type": "test"
49
+ }
50
+ }
51
+ }
52
+ EOS
53
+ assert_equal exp_template.chomp, act_template
54
+ end
55
+ end
@@ -0,0 +1,49 @@
1
+ require 'abstract_unit'
2
+
3
+ class Ec2DhcpOptionsTest < Minitest::Test
4
+ def test_normal
5
+ template = <<-EOS
6
+ _ec2_dhcp_options "test", domain_name: "test"
7
+ EOS
8
+ act_template = run_client_as_json(template)
9
+ exp_template = <<-EOS
10
+ {
11
+ "TestDhcpOptions": {
12
+ "Type": "AWS::EC2::DHCPOptions",
13
+ "Properties": {
14
+ "DomainName": "test",
15
+ "Tags": [
16
+ {
17
+ "Key": "Name",
18
+ "Value": {
19
+ "Fn::Join": [
20
+ "-",
21
+ [
22
+ {
23
+ "Ref": "Service"
24
+ },
25
+ "test"
26
+ ]
27
+ ]
28
+ }
29
+ },
30
+ {
31
+ "Key": "Service",
32
+ "Value": {
33
+ "Ref": "Service"
34
+ }
35
+ },
36
+ {
37
+ "Key": "Version",
38
+ "Value": {
39
+ "Ref": "Version"
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ }
46
+ EOS
47
+ assert_equal exp_template.chomp, act_template
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ require 'abstract_unit'
2
+
3
+ class Ec2EgressOnlyInternetGatewayTest < Minitest::Test
4
+ def test_normal
5
+ template = <<-EOS
6
+ _ec2_egress_only_internet_gateway "test", ref_vpc: "test"
7
+ EOS
8
+ act_template = run_client_as_json(template)
9
+ exp_template = <<-EOS
10
+ {
11
+ "TestEgressOnlyInternetGateway": {
12
+ "Type": "AWS::EC2::EgressOnlyInternetGateway",
13
+ "Properties": {
14
+ "VpcId": {
15
+ "Ref": "TestVpc"
16
+ }
17
+ }
18
+ }
19
+ }
20
+ EOS
21
+ assert_equal exp_template.chomp, act_template
22
+ end
23
+ end
@@ -84,7 +84,7 @@ _ec2_instance "test", key_name: "test", ref_instance_type: "test", ref_iam_insta
84
84
  ],
85
85
  "Tenancy": "default",
86
86
  "UserData": {
87
- "Fn::Base64": "#!/bin/bash\\ntest data"
87
+ "Fn::Base64": "#!/bin/bash\\ntest data\\n"
88
88
  }
89
89
  }
90
90
  }
@@ -0,0 +1,28 @@
1
+ require 'abstract_unit'
2
+
3
+ class Ec2NetworkInterfaceAttachmentTest < Minitest::Test
4
+ def test_normal
5
+ template = <<-EOS
6
+ _ec2_network_interface_attachment "test", ref_instance: "test", ref_network: "test"
7
+ EOS
8
+ act_template = run_client_as_json(template)
9
+ exp_template = <<-EOS
10
+ {
11
+ "TestNetworkInterfaceAttachment": {
12
+ "Type": "AWS::EC2::NetworkInterfaceAttachment",
13
+ "Properties": {
14
+ "DeleteOnTermination": "true",
15
+ "DeviceIndex": "0",
16
+ "InstanceId": {
17
+ "Ref": "TestInstance"
18
+ },
19
+ "NetworkInterfaceId": {
20
+ "Ref": "TestNetworkInterface"
21
+ }
22
+ }
23
+ }
24
+ }
25
+ EOS
26
+ assert_equal exp_template.chomp, act_template
27
+ end
28
+ end