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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/CHANGES.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE.md +22 -0
- data/README.md +139 -0
- data/Rakefile +7 -0
- data/lib/skywriter/function.rb +133 -0
- data/lib/skywriter/resource/auto_scaling/auto_scaling_group.rb +28 -0
- data/lib/skywriter/resource/auto_scaling/launch_configuration.rb +28 -0
- data/lib/skywriter/resource/auto_scaling/scaling_policy.rb +18 -0
- data/lib/skywriter/resource/auto_scaling/scheduled_action.rb +21 -0
- data/lib/skywriter/resource/auto_scaling/trigger.rb +26 -0
- data/lib/skywriter/resource/cloud_formation/authentication.rb +46 -0
- data/lib/skywriter/resource/cloud_formation/custom_resource.rb +17 -0
- data/lib/skywriter/resource/cloud_formation/stack.rb +15 -0
- data/lib/skywriter/resource/cloud_formation/wait_condition.rb +15 -0
- data/lib/skywriter/resource/cloud_formation/wait_condition_handle.rb +12 -0
- data/lib/skywriter/resource/cloud_front/distribution.rb +13 -0
- data/lib/skywriter/resource/cloud_watch/alarm.rb +27 -0
- data/lib/skywriter/resource/dynamo_db/table.rb +18 -0
- data/lib/skywriter/resource/ec2/customer_gateway.rb +16 -0
- data/lib/skywriter/resource/ec2/dhcp_options.rb +18 -0
- data/lib/skywriter/resource/ec2/eip.rb +14 -0
- data/lib/skywriter/resource/ec2/eip_association.rb +17 -0
- data/lib/skywriter/resource/ec2/instance.rb +34 -0
- data/lib/skywriter/resource/ec2/internet_gateway.rb +13 -0
- data/lib/skywriter/resource/ec2/network_acl.rb +14 -0
- data/lib/skywriter/resource/ec2/network_acl_entry.rb +20 -0
- data/lib/skywriter/resource/ec2/network_interface.rb +20 -0
- data/lib/skywriter/resource/ec2/network_interface_attachment.rb +16 -0
- data/lib/skywriter/resource/ec2/route.rb +17 -0
- data/lib/skywriter/resource/ec2/route_table.rb +14 -0
- data/lib/skywriter/resource/ec2/security_group.rb +17 -0
- data/lib/skywriter/resource/ec2/security_group_egress.rb +23 -0
- data/lib/skywriter/resource/ec2/security_group_ingress.rb +26 -0
- data/lib/skywriter/resource/ec2/subnet.rb +16 -0
- data/lib/skywriter/resource/ec2/subnet_network_acl_association.rb +14 -0
- data/lib/skywriter/resource/ec2/subnet_route_table_association.rb +14 -0
- data/lib/skywriter/resource/ec2/volume.rb +18 -0
- data/lib/skywriter/resource/ec2/volume_attachment.rb +15 -0
- data/lib/skywriter/resource/ec2/vpc.rb +17 -0
- data/lib/skywriter/resource/ec2/vpc_dhcp_options_association.rb +14 -0
- data/lib/skywriter/resource/ec2/vpc_gateway_attachment.rb +15 -0
- data/lib/skywriter/resource/ec2/vpn_connection.rb +17 -0
- data/lib/skywriter/resource/ec2/vpn_connection_route.rb +14 -0
- data/lib/skywriter/resource/ec2/vpn_gateway.rb +14 -0
- data/lib/skywriter/resource/ec2/vpn_gateway_route_propagation.rb +14 -0
- data/lib/skywriter/resource/elasti_cache/cache_cluster.rb +27 -0
- data/lib/skywriter/resource/elastic_beanstalk/application.rb +14 -0
- data/lib/skywriter/resource/elastic_beanstalk/application_version.rb +15 -0
- data/lib/skywriter/resource/elastic_beanstalk/configuration_template.rb +18 -0
- data/lib/skywriter/resource/elastic_beanstalk/environment.rb +21 -0
- data/lib/skywriter/resource/elastic_load_balancing/load_balancer.rb +25 -0
- data/lib/skywriter/resource/elasticache/parameter_group.rb +15 -0
- data/lib/skywriter/resource/elasticache/security_group.rb +13 -0
- data/lib/skywriter/resource/elasticache/security_group_ingress.rb +15 -0
- data/lib/skywriter/resource/elasticache/subnet_group.rb +14 -0
- data/lib/skywriter/resource/iam/access_key.rb +16 -0
- data/lib/skywriter/resource/iam/group.rb +15 -0
- data/lib/skywriter/resource/iam/instance_profile.rb +15 -0
- data/lib/skywriter/resource/iam/policy.rb +18 -0
- data/lib/skywriter/resource/iam/role.rb +13 -0
- data/lib/skywriter/resource/iam/user.rb +17 -0
- data/lib/skywriter/resource/iam/user_to_group_addition.rb +15 -0
- data/lib/skywriter/resource/logical_name_pointer.rb +11 -0
- data/lib/skywriter/resource/pointer.rb +23 -0
- data/lib/skywriter/resource/rds/db_instance.rb +37 -0
- data/lib/skywriter/resource/rds/db_parameter_group.rb +17 -0
- data/lib/skywriter/resource/rds/db_security_group.rb +17 -0
- data/lib/skywriter/resource/rds/db_security_group_ingress.rb +18 -0
- data/lib/skywriter/resource/rds/db_subnet_group.rb +16 -0
- data/lib/skywriter/resource/redshift/cluster.rb +37 -0
- data/lib/skywriter/resource/redshift/cluster_parameter_group.rb +16 -0
- data/lib/skywriter/resource/redshift/cluster_security_group.rb +14 -0
- data/lib/skywriter/resource/redshift/cluster_security_group_ingress.rb +17 -0
- data/lib/skywriter/resource/redshift/cluster_subnet_group.rb +15 -0
- data/lib/skywriter/resource/ref_pointer.rb +11 -0
- data/lib/skywriter/resource/route_53/record_set.rb +24 -0
- data/lib/skywriter/resource/route_53/record_set_group.rb +17 -0
- data/lib/skywriter/resource/s3/bucket.rb +17 -0
- data/lib/skywriter/resource/s3/bucket_policy.rb +15 -0
- data/lib/skywriter/resource/sdb/domain.rb +13 -0
- data/lib/skywriter/resource/sns/topic.rb +16 -0
- data/lib/skywriter/resource/sns/topic_policy.rb +15 -0
- data/lib/skywriter/resource/sqs/queue.rb +18 -0
- data/lib/skywriter/resource/sqs/queue_policy.rb +15 -0
- data/lib/skywriter/resource.rb +165 -0
- data/lib/skywriter/resource_property/README.md +64 -0
- data/lib/skywriter/resource_property/auto_scaling/block_device_mapping.rb +12 -0
- data/lib/skywriter/resource_property/auto_scaling/ebs_block_device.rb +17 -0
- data/lib/skywriter/resource_property/auto_scaling/notification_configuration.rb +11 -0
- data/lib/skywriter/resource_property/auto_scaling/tag.rb +15 -0
- data/lib/skywriter/resource_property/cloud_formation/resource_tag.rb +12 -0
- data/lib/skywriter/resource_property/cloud_front/cache_behavior.rb +14 -0
- data/lib/skywriter/resource_property/cloud_front/custom_origin.rb +11 -0
- data/lib/skywriter/resource_property/cloud_front/default_cache_behavior.rb +13 -0
- data/lib/skywriter/resource_property/cloud_front/distribution_config.rb +16 -0
- data/lib/skywriter/resource_property/cloud_front/forwarded_value.rb +13 -0
- data/lib/skywriter/resource_property/cloud_front/logging.rb +10 -0
- data/lib/skywriter/resource_property/cloud_front/origin.rb +12 -0
- data/lib/skywriter/resource_property/cloud_front/s3_origin.rb +9 -0
- data/lib/skywriter/resource_property/cloud_watch/metric_dimension.rb +10 -0
- data/lib/skywriter/resource_property/dynamo_db/attribute_definition.rb +12 -0
- data/lib/skywriter/resource_property/dynamo_db/global_secondary_index.rb +14 -0
- data/lib/skywriter/resource_property/dynamo_db/key_schema.rb +10 -0
- data/lib/skywriter/resource_property/dynamo_db/local_secondary_index.rb +13 -0
- data/lib/skywriter/resource_property/dynamo_db/projection.rb +12 -0
- data/lib/skywriter/resource_property/dynamo_db/provisioned_throughput.rb +10 -0
- data/lib/skywriter/resource_property/ec2/block_device_mapping.rb +12 -0
- data/lib/skywriter/resource_property/ec2/ebs_block_device.rb +15 -0
- data/lib/skywriter/resource_property/ec2/icmp.rb +10 -0
- data/lib/skywriter/resource_property/ec2/mount_point.rb +10 -0
- data/lib/skywriter/resource_property/ec2/network_interface.rb +18 -0
- data/lib/skywriter/resource_property/ec2/network_interface_association.rb +12 -0
- data/lib/skywriter/resource_property/ec2/network_interface_attachment.rb +10 -0
- data/lib/skywriter/resource_property/ec2/network_interface_group_item.rb +10 -0
- data/lib/skywriter/resource_property/ec2/network_interface_private_ip_specification.rb +10 -0
- data/lib/skywriter/resource_property/ec2/port_range.rb +10 -0
- data/lib/skywriter/resource_property/ec2/security_group_rule.rb +12 -0
- data/lib/skywriter/resource_property/ec2/tag.rb +10 -0
- data/lib/skywriter/resource_property/elastic_beanstalk/environment_tier.rb +11 -0
- data/lib/skywriter/resource_property/elastic_beanstalk/option_setting.rb +13 -0
- data/lib/skywriter/resource_property/elastic_beanstalk/source_bundle.rb +10 -0
- data/lib/skywriter/resource_property/elastic_beanstalk/source_configuration.rb +10 -0
- data/lib/skywriter/resource_property/elastic_load_balancing/app_cookie_stickiness_policy.rb +10 -0
- data/lib/skywriter/resource_property/elastic_load_balancing/health_check.rb +13 -0
- data/lib/skywriter/resource_property/elastic_load_balancing/lb_cookie_stickiness_policy.rb +10 -0
- data/lib/skywriter/resource_property/elastic_load_balancing/listener.rb +14 -0
- data/lib/skywriter/resource_property/elastic_load_balancing/policy.rb +13 -0
- data/lib/skywriter/resource_property/rds/security_group_rule.rb +12 -0
- data/lib/skywriter/resource_property/redshift/parameter.rb +10 -0
- data/lib/skywriter/resource_property/route53/alias_target.rb +10 -0
- data/lib/skywriter/resource_property/s3/website_configuration_policy.rb +16 -0
- data/lib/skywriter/resource_property/sns/subscription.rb +10 -0
- data/lib/skywriter/resource_property/sqs/redrive_policy.rb +10 -0
- data/lib/skywriter/resource_property.rb +57 -0
- data/lib/skywriter/template.rb +143 -0
- data/lib/skywriter/version.rb +3 -0
- data/lib/skywriter.rb +8 -0
- data/skywriter.gemspec +29 -0
- data/spec/skywriter/function_spec.rb +99 -0
- data/spec/skywriter/resource/cloud_formation/authentication_spec.rb +36 -0
- data/spec/skywriter/resource/cloud_formation/custom_resource_spec.rb +30 -0
- data/spec/skywriter/resource/logical_name_pointer_spec.rb +15 -0
- data/spec/skywriter/resource/ref_pointer_spec.rb +15 -0
- data/spec/skywriter/resource_property/ec2/security_group_rule_spec.rb +7 -0
- data/spec/skywriter/resource_property_spec.rb +153 -0
- data/spec/skywriter/resource_spec.rb +236 -0
- data/spec/skywriter/template_spec.rb +246 -0
- data/spec/spec_helper.rb +29 -0
- 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
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGES.md
ADDED
data/Gemfile
ADDED
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
|
+
[](https://travis-ci.org/otherinbox/skywriter)
|
|
3
|
+
[](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,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,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,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
|