skywriter 1.0.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.
Files changed (154) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGES.md +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.md +22 -0
  8. data/README.md +139 -0
  9. data/Rakefile +7 -0
  10. data/lib/skywriter/function.rb +133 -0
  11. data/lib/skywriter/resource/auto_scaling/auto_scaling_group.rb +28 -0
  12. data/lib/skywriter/resource/auto_scaling/launch_configuration.rb +28 -0
  13. data/lib/skywriter/resource/auto_scaling/scaling_policy.rb +18 -0
  14. data/lib/skywriter/resource/auto_scaling/scheduled_action.rb +21 -0
  15. data/lib/skywriter/resource/auto_scaling/trigger.rb +26 -0
  16. data/lib/skywriter/resource/cloud_formation/authentication.rb +46 -0
  17. data/lib/skywriter/resource/cloud_formation/custom_resource.rb +17 -0
  18. data/lib/skywriter/resource/cloud_formation/stack.rb +15 -0
  19. data/lib/skywriter/resource/cloud_formation/wait_condition.rb +15 -0
  20. data/lib/skywriter/resource/cloud_formation/wait_condition_handle.rb +12 -0
  21. data/lib/skywriter/resource/cloud_front/distribution.rb +13 -0
  22. data/lib/skywriter/resource/cloud_watch/alarm.rb +27 -0
  23. data/lib/skywriter/resource/dynamo_db/table.rb +18 -0
  24. data/lib/skywriter/resource/ec2/customer_gateway.rb +16 -0
  25. data/lib/skywriter/resource/ec2/dhcp_options.rb +18 -0
  26. data/lib/skywriter/resource/ec2/eip.rb +14 -0
  27. data/lib/skywriter/resource/ec2/eip_association.rb +17 -0
  28. data/lib/skywriter/resource/ec2/instance.rb +34 -0
  29. data/lib/skywriter/resource/ec2/internet_gateway.rb +13 -0
  30. data/lib/skywriter/resource/ec2/network_acl.rb +14 -0
  31. data/lib/skywriter/resource/ec2/network_acl_entry.rb +20 -0
  32. data/lib/skywriter/resource/ec2/network_interface.rb +20 -0
  33. data/lib/skywriter/resource/ec2/network_interface_attachment.rb +16 -0
  34. data/lib/skywriter/resource/ec2/route.rb +17 -0
  35. data/lib/skywriter/resource/ec2/route_table.rb +14 -0
  36. data/lib/skywriter/resource/ec2/security_group.rb +17 -0
  37. data/lib/skywriter/resource/ec2/security_group_egress.rb +23 -0
  38. data/lib/skywriter/resource/ec2/security_group_ingress.rb +26 -0
  39. data/lib/skywriter/resource/ec2/subnet.rb +16 -0
  40. data/lib/skywriter/resource/ec2/subnet_network_acl_association.rb +14 -0
  41. data/lib/skywriter/resource/ec2/subnet_route_table_association.rb +14 -0
  42. data/lib/skywriter/resource/ec2/volume.rb +18 -0
  43. data/lib/skywriter/resource/ec2/volume_attachment.rb +15 -0
  44. data/lib/skywriter/resource/ec2/vpc.rb +17 -0
  45. data/lib/skywriter/resource/ec2/vpc_dhcp_options_association.rb +14 -0
  46. data/lib/skywriter/resource/ec2/vpc_gateway_attachment.rb +15 -0
  47. data/lib/skywriter/resource/ec2/vpn_connection.rb +17 -0
  48. data/lib/skywriter/resource/ec2/vpn_connection_route.rb +14 -0
  49. data/lib/skywriter/resource/ec2/vpn_gateway.rb +14 -0
  50. data/lib/skywriter/resource/ec2/vpn_gateway_route_propagation.rb +14 -0
  51. data/lib/skywriter/resource/elasti_cache/cache_cluster.rb +27 -0
  52. data/lib/skywriter/resource/elastic_beanstalk/application.rb +14 -0
  53. data/lib/skywriter/resource/elastic_beanstalk/application_version.rb +15 -0
  54. data/lib/skywriter/resource/elastic_beanstalk/configuration_template.rb +18 -0
  55. data/lib/skywriter/resource/elastic_beanstalk/environment.rb +21 -0
  56. data/lib/skywriter/resource/elastic_load_balancing/load_balancer.rb +25 -0
  57. data/lib/skywriter/resource/elasticache/parameter_group.rb +15 -0
  58. data/lib/skywriter/resource/elasticache/security_group.rb +13 -0
  59. data/lib/skywriter/resource/elasticache/security_group_ingress.rb +15 -0
  60. data/lib/skywriter/resource/elasticache/subnet_group.rb +14 -0
  61. data/lib/skywriter/resource/iam/access_key.rb +16 -0
  62. data/lib/skywriter/resource/iam/group.rb +15 -0
  63. data/lib/skywriter/resource/iam/instance_profile.rb +15 -0
  64. data/lib/skywriter/resource/iam/policy.rb +18 -0
  65. data/lib/skywriter/resource/iam/role.rb +13 -0
  66. data/lib/skywriter/resource/iam/user.rb +17 -0
  67. data/lib/skywriter/resource/iam/user_to_group_addition.rb +15 -0
  68. data/lib/skywriter/resource/logical_name_pointer.rb +11 -0
  69. data/lib/skywriter/resource/pointer.rb +23 -0
  70. data/lib/skywriter/resource/rds/db_instance.rb +37 -0
  71. data/lib/skywriter/resource/rds/db_parameter_group.rb +17 -0
  72. data/lib/skywriter/resource/rds/db_security_group.rb +17 -0
  73. data/lib/skywriter/resource/rds/db_security_group_ingress.rb +18 -0
  74. data/lib/skywriter/resource/rds/db_subnet_group.rb +16 -0
  75. data/lib/skywriter/resource/redshift/cluster.rb +37 -0
  76. data/lib/skywriter/resource/redshift/cluster_parameter_group.rb +16 -0
  77. data/lib/skywriter/resource/redshift/cluster_security_group.rb +14 -0
  78. data/lib/skywriter/resource/redshift/cluster_security_group_ingress.rb +17 -0
  79. data/lib/skywriter/resource/redshift/cluster_subnet_group.rb +15 -0
  80. data/lib/skywriter/resource/ref_pointer.rb +11 -0
  81. data/lib/skywriter/resource/route_53/record_set.rb +24 -0
  82. data/lib/skywriter/resource/route_53/record_set_group.rb +17 -0
  83. data/lib/skywriter/resource/s3/bucket.rb +17 -0
  84. data/lib/skywriter/resource/s3/bucket_policy.rb +15 -0
  85. data/lib/skywriter/resource/sdb/domain.rb +13 -0
  86. data/lib/skywriter/resource/sns/topic.rb +16 -0
  87. data/lib/skywriter/resource/sns/topic_policy.rb +15 -0
  88. data/lib/skywriter/resource/sqs/queue.rb +18 -0
  89. data/lib/skywriter/resource/sqs/queue_policy.rb +15 -0
  90. data/lib/skywriter/resource.rb +165 -0
  91. data/lib/skywriter/resource_property/README.md +64 -0
  92. data/lib/skywriter/resource_property/auto_scaling/block_device_mapping.rb +12 -0
  93. data/lib/skywriter/resource_property/auto_scaling/ebs_block_device.rb +17 -0
  94. data/lib/skywriter/resource_property/auto_scaling/notification_configuration.rb +11 -0
  95. data/lib/skywriter/resource_property/auto_scaling/tag.rb +15 -0
  96. data/lib/skywriter/resource_property/cloud_formation/resource_tag.rb +12 -0
  97. data/lib/skywriter/resource_property/cloud_front/cache_behavior.rb +14 -0
  98. data/lib/skywriter/resource_property/cloud_front/custom_origin.rb +11 -0
  99. data/lib/skywriter/resource_property/cloud_front/default_cache_behavior.rb +13 -0
  100. data/lib/skywriter/resource_property/cloud_front/distribution_config.rb +16 -0
  101. data/lib/skywriter/resource_property/cloud_front/forwarded_value.rb +13 -0
  102. data/lib/skywriter/resource_property/cloud_front/logging.rb +10 -0
  103. data/lib/skywriter/resource_property/cloud_front/origin.rb +12 -0
  104. data/lib/skywriter/resource_property/cloud_front/s3_origin.rb +9 -0
  105. data/lib/skywriter/resource_property/cloud_watch/metric_dimension.rb +10 -0
  106. data/lib/skywriter/resource_property/dynamo_db/attribute_definition.rb +12 -0
  107. data/lib/skywriter/resource_property/dynamo_db/global_secondary_index.rb +14 -0
  108. data/lib/skywriter/resource_property/dynamo_db/key_schema.rb +10 -0
  109. data/lib/skywriter/resource_property/dynamo_db/local_secondary_index.rb +13 -0
  110. data/lib/skywriter/resource_property/dynamo_db/projection.rb +12 -0
  111. data/lib/skywriter/resource_property/dynamo_db/provisioned_throughput.rb +10 -0
  112. data/lib/skywriter/resource_property/ec2/block_device_mapping.rb +12 -0
  113. data/lib/skywriter/resource_property/ec2/ebs_block_device.rb +15 -0
  114. data/lib/skywriter/resource_property/ec2/icmp.rb +10 -0
  115. data/lib/skywriter/resource_property/ec2/mount_point.rb +10 -0
  116. data/lib/skywriter/resource_property/ec2/network_interface.rb +18 -0
  117. data/lib/skywriter/resource_property/ec2/network_interface_association.rb +12 -0
  118. data/lib/skywriter/resource_property/ec2/network_interface_attachment.rb +10 -0
  119. data/lib/skywriter/resource_property/ec2/network_interface_group_item.rb +10 -0
  120. data/lib/skywriter/resource_property/ec2/network_interface_private_ip_specification.rb +10 -0
  121. data/lib/skywriter/resource_property/ec2/port_range.rb +10 -0
  122. data/lib/skywriter/resource_property/ec2/security_group_rule.rb +12 -0
  123. data/lib/skywriter/resource_property/ec2/tag.rb +10 -0
  124. data/lib/skywriter/resource_property/elastic_beanstalk/environment_tier.rb +11 -0
  125. data/lib/skywriter/resource_property/elastic_beanstalk/option_setting.rb +13 -0
  126. data/lib/skywriter/resource_property/elastic_beanstalk/source_bundle.rb +10 -0
  127. data/lib/skywriter/resource_property/elastic_beanstalk/source_configuration.rb +10 -0
  128. data/lib/skywriter/resource_property/elastic_load_balancing/app_cookie_stickiness_policy.rb +10 -0
  129. data/lib/skywriter/resource_property/elastic_load_balancing/health_check.rb +13 -0
  130. data/lib/skywriter/resource_property/elastic_load_balancing/lb_cookie_stickiness_policy.rb +10 -0
  131. data/lib/skywriter/resource_property/elastic_load_balancing/listener.rb +14 -0
  132. data/lib/skywriter/resource_property/elastic_load_balancing/policy.rb +13 -0
  133. data/lib/skywriter/resource_property/rds/security_group_rule.rb +12 -0
  134. data/lib/skywriter/resource_property/redshift/parameter.rb +10 -0
  135. data/lib/skywriter/resource_property/route53/alias_target.rb +10 -0
  136. data/lib/skywriter/resource_property/s3/website_configuration_policy.rb +16 -0
  137. data/lib/skywriter/resource_property/sns/subscription.rb +10 -0
  138. data/lib/skywriter/resource_property/sqs/redrive_policy.rb +10 -0
  139. data/lib/skywriter/resource_property.rb +57 -0
  140. data/lib/skywriter/template.rb +143 -0
  141. data/lib/skywriter/version.rb +3 -0
  142. data/lib/skywriter.rb +8 -0
  143. data/skywriter.gemspec +29 -0
  144. data/spec/skywriter/function_spec.rb +99 -0
  145. data/spec/skywriter/resource/cloud_formation/authentication_spec.rb +36 -0
  146. data/spec/skywriter/resource/cloud_formation/custom_resource_spec.rb +30 -0
  147. data/spec/skywriter/resource/logical_name_pointer_spec.rb +15 -0
  148. data/spec/skywriter/resource/ref_pointer_spec.rb +15 -0
  149. data/spec/skywriter/resource_property/ec2/security_group_rule_spec.rb +7 -0
  150. data/spec/skywriter/resource_property_spec.rb +153 -0
  151. data/spec/skywriter/resource_spec.rb +236 -0
  152. data/spec/skywriter/template_spec.rb +246 -0
  153. data/spec/spec_helper.rb +29 -0
  154. metadata +306 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b6bcdd3dc26381dd3faf2f0d77d59796a1fba6e
4
+ data.tar.gz: c2cd5bb2a4bbdc44700a4a416becd8cc1b1e8b7b
5
+ SHA512:
6
+ metadata.gz: 0956c5fd85eca4883d6e707756e5c8be094132a7f9c3cde9a660272db1e92fab98dfe502b93f550a619f52dd3e8df1b1349b32ae11f03b6cb174ece6a8c23bf7
7
+ data.tar.gz: bdb99f0ea00674303d8763dd81c2728575d15b7914feb41c2a797cd90532f3245793276ae47b986bdb2d3d1c4d0cfbe29b0a2eb51c7078708447d2f0278f5628
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rbenv*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - jruby-19mode
7
+ script:
8
+ - bundle exec rake
data/CHANGES.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changes
2
+
3
+ ## 1.0.0
4
+
5
+ * Initial release. - Ben Hamill, Ryan Michael, Josh Smith, Peter Whiteside
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in skywriter.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Return Path
2
+
3
+ # MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # Skywriter
2
+ [![Build Status](https://travis-ci.org/otherinbox/skywriter.png?branch=master)](https://travis-ci.org/otherinbox/skywriter)
3
+ [![Code Climate](https://codeclimate.com/github/otherinbox/skywriter.png)](https://codeclimate.com/github/otherinbox/skywriter)
4
+
5
+ Skywriter makes writing CloudFormation templates easier.
6
+
7
+ Writing and, more importantly, maintaining large JSON files can be a real pain.
8
+ Skywriter aims to alleviate some of that pain by letting you use code to
9
+ generate the JSON and, instead, maintain a Ruby file. Defining your template in
10
+ runnable code provides some benefits like variable assignment, that make the
11
+ need to use CloudFormation's build-in functions superfluous (of course,
12
+ Skywriter still has helpers for those functions, if you need them).
13
+
14
+
15
+ ## Features
16
+
17
+ ### Automatic Dependencies
18
+
19
+ When you are creating a resource, references to other resources will be added to
20
+ the `DependsOn` key automatically. If you have additional dependencies which
21
+ should be included in this key, they can be declared like this:
22
+
23
+ ``` ruby
24
+ Resource.new(
25
+ "ResourceName",
26
+ additional_dependencies: ['foo', 'bar'],
27
+ some_property: other_resource.as_pointer,
28
+ ).as_json
29
+
30
+ # yields:
31
+ # { "ResourceName" => {
32
+ # "Parameters" => {
33
+ # "SomeProperty" => {"Ref" => "OtherResource"}
34
+ # },
35
+ # "DependsOn" => ["foo", "bar", "OtherResource"]
36
+ # }}
37
+ ```
38
+
39
+ See the example section below for some more concrete examples.
40
+
41
+
42
+ ## Examples
43
+
44
+ This example will build a basic VPC with an Internet Gateway. It uses a pointer to reference the VpcId in the Gateway Attachment resource.
45
+ It then creates a Cloudformation template from the resources.
46
+
47
+ ``` ruby
48
+ my_vpc = Skywriter::Resource::EC2::VPC.new(
49
+ "myVPC",
50
+ cidr_block: "10.10.0.0/16",
51
+ tags: { network: "public" }
52
+ )
53
+
54
+ my_igw = Skywriter::Resource::EC2::InternetGateway.new(
55
+ "myInternetGateway",
56
+ tags: { network: "public" }
57
+ )
58
+
59
+ my_gateway_attachment = Skywriter::Resource::EC2::VPCGatewayAttachment.new(
60
+ "myGatewayAttachment",
61
+ vpc_id: my_vpc.as_pointer
62
+ )
63
+
64
+ Skywriter::Template.new(
65
+ description: "This is a test template",
66
+ resources: [my_vpc, my_igw, my_gateway_attachment]
67
+ ).as_json
68
+ ```
69
+
70
+ Here we create an EC2 security group that is accessible on ports 80 and 22. The ec2 security group is added into the ingress for a database security group by using a pointer that references the logical name of the resource.
71
+ The new database security group, as well as an old one that already exists in our account, are both applied to a database instance resource.
72
+
73
+ ``` ruby
74
+ my_ec2_sg = Skywriter::Resource::EC2::SecurityGroup.new(
75
+ "ec2_security_group",
76
+ GroupDescription: "a security group for my ec2 instances",
77
+ SecurityGroupIngress: [
78
+ Skywriter::ResourceProperty::EC2::SecurityGroupRule.new(
79
+ FromPort: 80,
80
+ ToPort: 80,
81
+ IpProtocol: "tcp"
82
+ ),
83
+ Skywriter::ResourceProperty::EC2::SecurityGroupRule.new(
84
+ FromPort: 22,
85
+ ToPort: 22,
86
+ IpProtocol: "tcp"
87
+ )
88
+ ]
89
+ )
90
+
91
+ my_db_sg = Skywriter::Resource::RDS::DBSecurityGroup.new(
92
+ "database_security_group",
93
+ DBSecurityGroupIngress: Skywriter::ResourceProperty::RDS::SecurityGroupRule.new(
94
+ EC2SecurityGroupName: my_ec2_sg.as_pointer(with: :logical_name)
95
+ )
96
+ )
97
+
98
+ my_db = Skywriter::Resource::RDS::DBInstance.new(
99
+ "mysql_database",
100
+ allocated_storage: 5,
101
+ availability_zone: "us-east-1a",
102
+ db_name: "my_db",
103
+ engine: "MySQL",
104
+ db_security_groups: ["old_sg", my_db_sg.as_pointer]
105
+ )
106
+
107
+
108
+ Skywriter::Template.new(
109
+ resources: [my_ec2_sg, my_db_sg, my_db]
110
+ ).as_json
111
+ ```
112
+
113
+
114
+ ## Contributing
115
+
116
+ Help is gladly welcomed. If you have a feature you'd like to add, it's much more
117
+ likely to get in (or get in faster) the closer you stick to these steps:
118
+
119
+ 1. Open an Issue to talk about it. We can discuss whether it's the right
120
+ direction or maybe help track down a bug, etc.
121
+ 1. Fork the project, and make a branch to work on your feature/fix. Master is
122
+ where you'll want to start from.
123
+ 1. Turn the Issue into a Pull Request. There are several ways to do this, but
124
+ [hub](https://github.com/defunkt/hub) is probably the easiest.
125
+ 1. Make sure your Pull Request includes tests.
126
+ 1. Bonus points if your Pull Request updates `CHANGES.md` to include a summary
127
+ of your changes and your name like the other entries. If the last entry is
128
+ the last release, add a new `## Unreleased` heading.
129
+
130
+ If you don't know how to fix something, even just a Pull Request that includes a
131
+ failing test can be helpful. If in doubt, make an Issue to discuss.
132
+
133
+
134
+ ## Copyright
135
+
136
+ Copyright © 2014 Return Path.
137
+
138
+ This gem is distributed under the MIT License. See [LICENSE.md](LICENSE.md) for
139
+ details.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,133 @@
1
+ module Skywriter
2
+ module Function
3
+ # Intrinstic function 'Ref'
4
+ #
5
+ # @param logical_name The logical name of the resource or parameter you want to dereference
6
+ #
7
+ # @return [Hash] A hash describing the function
8
+ #
9
+ def self.ref(logical_name)
10
+ { "Ref" => logical_name }
11
+ end
12
+
13
+ # Intrinsic function Fn::Base64
14
+ #
15
+ # @param value The string value you want to convert to Base64.
16
+ #
17
+ # @return [Hash] A hash describing the function
18
+ #
19
+ def self.base64(value)
20
+ { "Fn::Base64" => value }
21
+ end
22
+
23
+ # Intrinsic function Fn::FindInMap
24
+ #
25
+ # @param map The logical name of a mapping declared in the Mappings section that contains the keys and values.
26
+ # @param *keys A list describing the n-th level keys to index
27
+ #
28
+ # @return [Hash] A hash describing the function
29
+ #
30
+ def self.find_in_map(map, *keys)
31
+ { "Fn::FindInMap" => Array(map) + keys }
32
+ end
33
+
34
+ # Intrinsic function Fn::GetAtt
35
+ #
36
+ # @param resource_name The logical name of the resource that contains the attribute you want.
37
+ # @param attribute_name The name of the resource-specific attribute whose value you want.
38
+ #
39
+ # @return [Hash] A hash describing the function
40
+ #
41
+ def self.get_att(resource_name, attribute_name)
42
+ { "Fn::GetAtt" => [resource_name, attribute_name] }
43
+ end
44
+
45
+ # Intrinsic function Fn::GetAZs
46
+ #
47
+ # @param region The name of the region for which you want to get the Availability Zones.
48
+ #
49
+ # @return [Hash] A hash describing the function
50
+ #
51
+ def self.get_azs(region = nil)
52
+ { "Fn::GetAZs" => region.to_s }
53
+ end
54
+
55
+ # Intrinsic function Fn::Join
56
+ #
57
+ # @param sep The value you want to occur between values
58
+ # @param *values The values you wish to join
59
+ #
60
+ # @return [Hash] A hash describing the function
61
+ #
62
+ def self.join(sep, *values)
63
+ { "Fn::Join" => [sep.to_s, values] }
64
+ end
65
+
66
+ # Intrinsic function Fn::Select
67
+ #
68
+ # @param index The index of the object to retrieve, zero-indexed
69
+ # @param *values The list of objects to select from
70
+ #
71
+ # @return [Hash] A hash describing the function
72
+ #
73
+ def self.select(index, *values)
74
+ { "Fn::Select" => [index.to_s, values] }
75
+ end
76
+
77
+
78
+ # Conditionals
79
+
80
+ # Intrinsic conditional function Fn::And
81
+ #
82
+ # @param *conditions Conditions that evaluate to true or false.
83
+ #
84
+ # @return [Hash] A hash describing the conditional function
85
+ #
86
+ def self.and(*conditions)
87
+ { "Fn::And" => conditions }
88
+ end
89
+
90
+ # Intrinsic conditional function Fn::Equals
91
+ #
92
+ # @param left A value of any type that you want to compare.
93
+ # @param right A value of any type that you want to compare.
94
+ #
95
+ # @return [Hash] A hash describing the conditional function
96
+ #
97
+ def self.equals(left, right)
98
+ { "Fn::Equals" => [left, right] }
99
+ end
100
+
101
+ # Intrinsic conditional function Fn::If
102
+ #
103
+ # @param condition A reference to a condition in the Conditions section
104
+ # @param when_true A value to be returned if the specified condition evaluates to true
105
+ # @param when_false A value to be returned if the specified condition evaluates to false
106
+ #
107
+ # @return [Hash] A hash describing the conditional function
108
+ #
109
+ def self.if(condition, when_true, when_false)
110
+ { "Fn::If" => [condition, when_true, when_false] }
111
+ end
112
+
113
+ # Intrinsic conditional function Fn::Not
114
+ #
115
+ # @param condition A condition such as Fn::Equals that evaluates to true or false
116
+ #
117
+ # @return [Hash] A hash describing the conditional function
118
+ #
119
+ def self.not(condition)
120
+ { "Fn::Not" => [condition] }
121
+ end
122
+
123
+ # Intrinsic conditional function Fn::Or
124
+ #
125
+ # @param *conditions Conditions that evaluate to true or false
126
+ #
127
+ # @return [Hash] A hash describing the conditional function
128
+ #
129
+ def self.or(*conditions)
130
+ { "Fn::Or" => conditions }
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,28 @@
1
+ module Skywriter
2
+ module Resource
3
+ module AutoScaling
4
+ # AWS::AutoScaling::AutoScalingGroup Resource
5
+ #
6
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html
7
+ #
8
+ class AutoScalingGroup
9
+ include Skywriter::Resource
10
+
11
+ property :AvailabilityZones
12
+ property :Cooldown
13
+ property :DesiredCapacity
14
+ property :HealthCheckGracePeriod
15
+ property :HealthCheckType
16
+ property :InstanceId
17
+ property :LaunchConfigurationName
18
+ property :LoadBalancerNames
19
+ property :MaxSize
20
+ property :MinSize
21
+ property :NotificationConfiguration
22
+ property :Tags
23
+ property :TerminationPolicies
24
+ property :VPCZoneIdentifier
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module Skywriter
2
+ module Resource
3
+ module AutoScaling
4
+ # AWS::AutoScaling::LaunchConfiguration Resource
5
+ #
6
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig.html
7
+ #
8
+ class LaunchConfiguration
9
+ include Skywriter::Resource
10
+
11
+ property :AssociatePublicIpAddress
12
+ property :BlockDeviceMappings
13
+ property :EbsOptimized
14
+ property :IamInstanceProfile
15
+ property :ImageId
16
+ property :InstanceId
17
+ property :InstanceMonitoring
18
+ property :InstanceType
19
+ property :KernelId
20
+ property :KeyName
21
+ property :RamDiskId
22
+ property :SecurityGroups
23
+ property :SpotPrice
24
+ property :UserData
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ module Skywriter
2
+ module Resource
3
+ module AutoScaling
4
+ # AWS::AutoScaling::ScalingPolicy Resource
5
+ #
6
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-policy.html
7
+ #
8
+ class ScalingPolicy
9
+ include Skywriter::Resource
10
+
11
+ property :AdjustmentType
12
+ property :AutoScalingGroupName
13
+ property :Cooldown
14
+ property :ScalingAdjustment
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module Skywriter
2
+ module Resource
3
+ module AutoScaling
4
+ # AWS::AutoScaling::ScheduledAction Resource
5
+ #
6
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-as-scheduledaction.html
7
+ #
8
+ class ScheduledAction
9
+ include Skywriter::Resource
10
+
11
+ property :AutoScalingGroupName
12
+ property :DesiredCapacity
13
+ property :EndTime
14
+ property :MaxSize
15
+ property :MinSize
16
+ property :Recurrence
17
+ property :StartTime
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ module Skywriter
2
+ module Resource
3
+ module AutoScaling
4
+ # AWS::AutoScaling::Trigger Resource
5
+ #
6
+ # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-trigger.html
7
+ #
8
+ class Trigger
9
+ include Skywriter::Resource
10
+
11
+ property :AutoScalingGroupName
12
+ property :BreachDuration
13
+ property :Dimensions
14
+ property :LowerBreachScaleIncrement
15
+ property :LowerThreshold
16
+ property :MetricName
17
+ property :Namespace
18
+ property :Period
19
+ property :Statistic
20
+ property :Unit
21
+ property :UpperBreachScaleIncrement
22
+ property :UpperThreshold
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,46 @@
1
+ module Skywriter
2
+ module Resource
3
+ module CloudFormation
4
+ # AWS::CloudFormation::Authentication Resource
5
+ #
6
+ class Authentication
7
+ include Skywriter::Resource
8
+
9
+ property :accessKeyId
10
+ property :buckets
11
+ property :password
12
+ property :secretKey
13
+ property :type
14
+ property :uris
15
+ property :username
16
+ property :roleName
17
+
18
+ def as_json
19
+ Thread.current[:skywriter_as_json_context] = self
20
+
21
+ as_json = { logical_name => { 'Type' => type } }
22
+
23
+ options.each do |top_level_key, properties|
24
+ as_json[logical_name][top_level_key.to_s] = properties(properties).as_json
25
+ end
26
+
27
+ as_json[logical_name]['DependsOn'] = all_dependencies
28
+
29
+ return as_json
30
+ ensure
31
+ Thread.current[:skywriter_as_json_context] = nil
32
+ end
33
+
34
+ private
35
+
36
+ def properties(properties)
37
+ property_definitions.each_with_object({}) do |property_definition, hash|
38
+ if (value = properties[property_definition.key])
39
+ hash[property_definition.name] = value
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ module Skywriter
2
+ module Resource
3
+ module CloudFormation
4
+ # AWS::CloudFormation::CustomResource Resource
5
+ #
6
+ class CustomResource
7
+ include Skywriter::Resource
8
+
9
+ private
10
+
11
+ def properties
12
+ @options
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module Skywriter
2
+ module Resource
3
+ module CloudFormation
4
+ # AWS::CloudFormation::Stack Resource
5
+ #
6
+ class Stack
7
+ include Skywriter::Resource
8
+
9
+ property :TemplateURL
10
+ property :TimeoutInMinutes
11
+ property :Parameters
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Skywriter
2
+ module Resource
3
+ module CloudFormation
4
+ # AWS::CloudFormation::WaitCondition Resource
5
+ #
6
+ class WaitCondition
7
+ include Skywriter::Resource
8
+
9
+ property :Count
10
+ property :Handle
11
+ property :Timeout
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Skywriter
2
+ module Resource
3
+ module CloudFormation
4
+ # AWS::CloudFormation::WaitConditionHandle Resource
5
+ #
6
+ class WaitConditionHandle
7
+ include Skywriter::Resource
8
+
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Skywriter
2
+ module Resource
3
+ module CloudFront
4
+ # AWS::CloudFront::Distribution Resource
5
+ #
6
+ class Distribution
7
+ include Skywriter::Resource
8
+
9
+ property :DistributionConfig
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ module Skywriter
2
+ module Resource
3
+ module CloudWatch
4
+ # AWS::CloudWatch::Alarm Resource
5
+ #
6
+ class Alarm
7
+ include Skywriter::Resource
8
+
9
+ property :ActionsEnabled
10
+ property :AlarmActions
11
+ property :AlarmDescription
12
+ property :AlarmName
13
+ property :ComparisonOperator
14
+ property :Dimensions
15
+ property :EvaluationPeriods
16
+ property :InsufficientDataActions
17
+ property :MetricName
18
+ property :Namespace
19
+ property :OKActions
20
+ property :Period
21
+ property :Statistic
22
+ property :Threshold
23
+ property :Unit
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ module Skywriter
2
+ module Resource
3
+ module DynamoDB
4
+ # AWS::DynamoDB::Table Resource
5
+ #
6
+ class Table
7
+ include Skywriter::Resource
8
+
9
+ property :AttributeDefinitions
10
+ property :GlobalSecondaryIndexes
11
+ property :KeySchema
12
+ property :LocalSecondaryIndexes
13
+ property :ProvisionedThroughput
14
+ property :TableName
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module Skywriter
2
+ module Resource
3
+ module EC2
4
+ # AWS::EC2::CustomerGateway Resource
5
+ #
6
+ class CustomerGateway
7
+ include Skywriter::Resource
8
+
9
+ property :BgpAsn
10
+ property :IpAddress
11
+ property :Tags
12
+ property :Type
13
+ end
14
+ end
15
+ end
16
+ end