draw_cloud 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +22 -0
- data/lib/draw_cloud.rb +75 -0
- data/lib/draw_cloud/as_group.rb +104 -0
- data/lib/draw_cloud/as_group.rb~ +54 -0
- data/lib/draw_cloud/as_launch_configuration.rb +71 -0
- data/lib/draw_cloud/as_launch_configuration.rb~ +50 -0
- data/lib/draw_cloud/base.rb +264 -0
- data/lib/draw_cloud/base64_func.rb +30 -0
- data/lib/draw_cloud/configuration.rb +61 -0
- data/lib/draw_cloud/configuration.rb~ +64 -0
- data/lib/draw_cloud/ec2_instance.rb +141 -0
- data/lib/draw_cloud/ec2_instance.rb~ +78 -0
- data/lib/draw_cloud/ec2_instance_template.rb +29 -0
- data/lib/draw_cloud/ec2_instance_template.rb~ +36 -0
- data/lib/draw_cloud/elastic_ip.rb +97 -0
- data/lib/draw_cloud/elastic_ip.rb~ +19 -0
- data/lib/draw_cloud/get_att_func.rb +31 -0
- data/lib/draw_cloud/get_att_func.rb~ +19 -0
- data/lib/draw_cloud/iam_access_key.rb +53 -0
- data/lib/draw_cloud/iam_access_key.rb~ +43 -0
- data/lib/draw_cloud/iam_policy.rb +71 -0
- data/lib/draw_cloud/iam_policy.rb~ +41 -0
- data/lib/draw_cloud/iam_user.rb +53 -0
- data/lib/draw_cloud/iam_user.rb~ +44 -0
- data/lib/draw_cloud/internet_gateway.rb +66 -0
- data/lib/draw_cloud/join_func.rb +31 -0
- data/lib/draw_cloud/join_func.rb~ +24 -0
- data/lib/draw_cloud/locations.rb +25 -0
- data/lib/draw_cloud/locations.rb~ +53 -0
- data/lib/draw_cloud/map.rb +65 -0
- data/lib/draw_cloud/network_acl.rb +91 -0
- data/lib/draw_cloud/network_acl.rb~ +36 -0
- data/lib/draw_cloud/network_acl_entry.rb +110 -0
- data/lib/draw_cloud/network_acl_entry.rb~ +36 -0
- data/lib/draw_cloud/network_interface.rb +71 -0
- data/lib/draw_cloud/network_interface.rb~ +46 -0
- data/lib/draw_cloud/output.rb +38 -0
- data/lib/draw_cloud/output.rb~ +39 -0
- data/lib/draw_cloud/parameter.rb +58 -0
- data/lib/draw_cloud/parameter.rb~ +30 -0
- data/lib/draw_cloud/rds_instance.rb +117 -0
- data/lib/draw_cloud/rds_security_group.rb +57 -0
- data/lib/draw_cloud/route_table.rb +56 -0
- data/lib/draw_cloud/route_table_entry.rb +59 -0
- data/lib/draw_cloud/route_table_entry.rb~ +33 -0
- data/lib/draw_cloud/s3_bucket.rb~ +41 -0
- data/lib/draw_cloud/security_group.rb +85 -0
- data/lib/draw_cloud/security_group.rb~ +71 -0
- data/lib/draw_cloud/service.rb~ +75 -0
- data/lib/draw_cloud/simple_ref.rb +30 -0
- data/lib/draw_cloud/simple_ref.rb~ +17 -0
- data/lib/draw_cloud/sns_topic.rb +58 -0
- data/lib/draw_cloud/sns_topic.rb~ +39 -0
- data/lib/draw_cloud/subnet.rb +104 -0
- data/lib/draw_cloud/subnet.rb~ +56 -0
- data/lib/draw_cloud/utilities.rb +65 -0
- data/lib/draw_cloud/version.rb +3 -0
- data/lib/draw_cloud/vpc.rb +57 -0
- data/lib/draw_cloud/vpc.rb~ +55 -0
- data/lib/draw_cloud/wait_handle.rb +78 -0
- data/lib/draw_cloud/wait_handle.rb~ +10 -0
- metadata +195 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) 2012, SweetSpot Diabetes Care, Inc.
|
4
|
+
# License:: All rights reserved
|
5
|
+
#
|
6
|
+
|
7
|
+
module DrawCloud
|
8
|
+
class SimpleRef
|
9
|
+
def initialize(literal)
|
10
|
+
@literal = literal
|
11
|
+
end
|
12
|
+
|
13
|
+
def ref
|
14
|
+
{"Ref" => literal}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) 2013, SweetSpot Diabetes Care, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
6
|
+
# may not use this work except in compliance with the License. You may
|
7
|
+
# obtain a copy of the License in the LICENSE file, or at:
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
14
|
+
# implied. See the License for the specific language governing
|
15
|
+
# permissions and limitations under the License.
|
16
|
+
|
17
|
+
#
|
18
|
+
|
19
|
+
module DrawCloud
|
20
|
+
class SNSTopic < Base
|
21
|
+
attr_accessor( :name,
|
22
|
+
:display_name,
|
23
|
+
:subscriptions )
|
24
|
+
def initialize(name, options={}, &block)
|
25
|
+
@name = name
|
26
|
+
@subscriptions = options.fetch(:subscriptions, [])
|
27
|
+
super(options, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_subscription(endpoint, protocol)
|
31
|
+
subscriptions << {:endpoint => endpoint, :protocol => protocol}
|
32
|
+
end
|
33
|
+
|
34
|
+
def sns_topic
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_into_config(config)
|
39
|
+
config.cf_add_resource resource_name, self
|
40
|
+
super(config)
|
41
|
+
end
|
42
|
+
|
43
|
+
def resource_name
|
44
|
+
resource_style(name) + "SNSTopic"
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_h
|
48
|
+
h = {
|
49
|
+
"Type" => "AWS::SNS::Topic",
|
50
|
+
"Properties" => {
|
51
|
+
"Subscription" => subscriptions.collect {|s| {"Endpoint" => DrawCloud.ref(s[:endpoint]), "Protocol" => DrawCloud.ref(s[:protocol])} }
|
52
|
+
}
|
53
|
+
}
|
54
|
+
h["Properties"]["DisplayName"] = DrawCloud.ref(display_name) if display_name
|
55
|
+
h
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) 2013, SweetSpot Diabetes Care, Inc.
|
4
|
+
# License:: All rights reserved
|
5
|
+
#
|
6
|
+
|
7
|
+
module DrawCloud
|
8
|
+
class SNSTopic < Base
|
9
|
+
attr_accessor( :name,
|
10
|
+
:display_name,
|
11
|
+
:subscriptions )
|
12
|
+
def initialize(name, options={}, &block)
|
13
|
+
@name = name
|
14
|
+
@subscriptions = options.fetch(:subscriptions, [])
|
15
|
+
super(options, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_subscription(endpoint, protocol)
|
19
|
+
subscriptions << {:endpoint => endpoint, :protocol => protocol}
|
20
|
+
end
|
21
|
+
|
22
|
+
def sns_topic
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_into_config(config)
|
27
|
+
config.cf_add_resource resource_name, self
|
28
|
+
super(config)
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_h
|
32
|
+
h = {
|
33
|
+
"Type" => "AWS::SNS::Topic",
|
34
|
+
"Properties" => {
|
35
|
+
"Subscription" => subscriptions.collect {|s|
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) 2012, SweetSpot Diabetes Care, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
6
|
+
# may not use this work except in compliance with the License. You may
|
7
|
+
# obtain a copy of the License in the LICENSE file, or at:
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
14
|
+
# implied. See the License for the specific language governing
|
15
|
+
# permissions and limitations under the License.
|
16
|
+
|
17
|
+
#
|
18
|
+
|
19
|
+
module DrawCloud
|
20
|
+
class Subnet < Base
|
21
|
+
class SubnetRouteTableAssociation
|
22
|
+
attr_accessor :subnet, :route_table
|
23
|
+
def initialize(subnet, route_table)
|
24
|
+
@subnet = subnet
|
25
|
+
@route_table = route_table
|
26
|
+
end
|
27
|
+
|
28
|
+
def resource_name
|
29
|
+
subnet.resource_name + "RouteTableAssociation"
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_h
|
33
|
+
{ "Type" => "AWS::EC2::SubnetRouteTableAssociation",
|
34
|
+
"Properties" => {
|
35
|
+
"SubnetId" => DrawCloud.ref(subnet),
|
36
|
+
"RouteTableId" => DrawCloud.ref(route_table),
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class SubnetNetworkAclAssociation
|
43
|
+
attr_accessor :subnet, :network_acl
|
44
|
+
def initialize(subnet, network_acl)
|
45
|
+
@subnet = subnet
|
46
|
+
@network_acl = network_acl
|
47
|
+
end
|
48
|
+
|
49
|
+
def resource_name
|
50
|
+
subnet.resource_name + "NetworkAclAssociation"
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_h
|
54
|
+
{ "Type" => "AWS::EC2::SubnetNetworkAclAssociation",
|
55
|
+
"Properties" => {
|
56
|
+
"SubnetId" => DrawCloud.ref(subnet),
|
57
|
+
"NetworkAclId" => DrawCloud.ref(network_acl),
|
58
|
+
}
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
attr_accessor :name, :cidr, :availability_zone, :route_table, :network_acl
|
64
|
+
def initialize(name, cidr, options={}, &block)
|
65
|
+
@name = name
|
66
|
+
@cidr = cidr
|
67
|
+
@availability_zone = options.fetch(:availability_zone, nil)
|
68
|
+
@route_table = options.fetch(:route_table, nil)
|
69
|
+
@network_acl = options.fetch(:network_acl, nil)
|
70
|
+
super(options, &block)
|
71
|
+
end
|
72
|
+
|
73
|
+
def subnet
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def load_into_config(config)
|
78
|
+
config.cf_add_resource resource_name, self
|
79
|
+
if route_table
|
80
|
+
route_table.load_into_config(config)
|
81
|
+
assoc = SubnetRouteTableAssociation.new(self, route_table)
|
82
|
+
config.cf_add_resource assoc.resource_name, assoc
|
83
|
+
end
|
84
|
+
if network_acl
|
85
|
+
network_acl.load_into_config(config)
|
86
|
+
assoc = SubnetNetworkAclAssociation.new(self, network_acl)
|
87
|
+
config.cf_add_resource assoc.resource_name, assoc
|
88
|
+
end
|
89
|
+
super(config)
|
90
|
+
end
|
91
|
+
|
92
|
+
def to_h
|
93
|
+
h = {
|
94
|
+
"Type" => "AWS::EC2::Subnet",
|
95
|
+
"Properties" => {
|
96
|
+
"CidrBlock" => cidr,
|
97
|
+
}
|
98
|
+
}
|
99
|
+
h["Properties"]["VpcId"] = DrawCloud.ref(vpc) if vpc
|
100
|
+
h["Properties"]["AvailabilityZone"] = DrawCloud.ref(@availability_zone) if @availability_zone
|
101
|
+
add_standard_properties(h)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module DrawCloud
|
2
|
+
class Subnet
|
3
|
+
include Base
|
4
|
+
|
5
|
+
class SubnetRouteTableAssociation
|
6
|
+
attr_accessor :subnet, :route_table
|
7
|
+
def initialize(subnet, route_table)
|
8
|
+
@subnet = subnet
|
9
|
+
@route_table = route_table
|
10
|
+
end
|
11
|
+
|
12
|
+
def resource_name
|
13
|
+
subnet.resource_name + "RouteTableAssociation"
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_h
|
17
|
+
{ "Type" => "AWS::EC2::SubnetRouteTableAssociation",
|
18
|
+
"Properties" => {
|
19
|
+
"SubnetId" => subnet.ref,
|
20
|
+
"RouteTableId" => route_table.ref,
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_accessor :name, :vpc, :cidr, :availability_zone, :route_table
|
27
|
+
def initialize(name, cidr, options={})
|
28
|
+
@name = name
|
29
|
+
@cidr = cidr
|
30
|
+
@vpc = options.fetch(:vpc, nil)
|
31
|
+
@availability_zone = options.fetch(:availability_zone, nil)
|
32
|
+
@route_table = options.fetch(:route_table, nil)
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_into_config(config)
|
36
|
+
config.cf_add_resource resource_name, self
|
37
|
+
if @route_table
|
38
|
+
@route_table.load_into_config(config)
|
39
|
+
assoc = SubnetRouteTableAssociation.new(self, @route_table)
|
40
|
+
config.cf_add_resource assoc.resource_name, assoc
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_h
|
45
|
+
h = {
|
46
|
+
"Type" => "AWS::EC2::Subnet",
|
47
|
+
"Properties" => {
|
48
|
+
"CidrBlock" => @cidr,
|
49
|
+
}
|
50
|
+
}
|
51
|
+
h["Properties"]["VpcId"] = @vpc.ref if @vpc
|
52
|
+
h["Properties"]["AvailabilityZone"] = @availability_zone.ref if @availability_zone
|
53
|
+
h
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) 2012, SweetSpot Diabetes Care, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
6
|
+
# may not use this work except in compliance with the License. You may
|
7
|
+
# obtain a copy of the License in the LICENSE file, or at:
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
14
|
+
# implied. See the License for the specific language governing
|
15
|
+
# permissions and limitations under the License.
|
16
|
+
|
17
|
+
#
|
18
|
+
|
19
|
+
module DrawCloud
|
20
|
+
module Utilities
|
21
|
+
def region
|
22
|
+
SimpleRef.new("AWS::Region")
|
23
|
+
end
|
24
|
+
|
25
|
+
def stack_name
|
26
|
+
SimpleRef.new("AWS::StackName")
|
27
|
+
end
|
28
|
+
|
29
|
+
def fngetatt(resource, attribute_name)
|
30
|
+
GetAttFunc.new(resource, attribute_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def fnbase64(arg)
|
34
|
+
Base64Func.new(arg)
|
35
|
+
end
|
36
|
+
|
37
|
+
def fnjoin(delimiter, *args)
|
38
|
+
JoinFunc.new(delimiter, args)
|
39
|
+
end
|
40
|
+
|
41
|
+
def resource_style(str)
|
42
|
+
DrawCloud.resource_style(str)
|
43
|
+
end
|
44
|
+
|
45
|
+
def desplice(string)
|
46
|
+
fnjoin("", *string.split('|CHOPHERE|').collect {|s| if s.start_with? 'YYYY' then YAML::load(s[4,s.length-4]) else s end })
|
47
|
+
end
|
48
|
+
|
49
|
+
def splice(string)
|
50
|
+
out = '|CHOPHERE|'
|
51
|
+
outref = DrawCloud.ref(string)
|
52
|
+
case outref
|
53
|
+
when String
|
54
|
+
out += outref
|
55
|
+
else
|
56
|
+
out += 'YYYY' + YAML::dump(outref)
|
57
|
+
end
|
58
|
+
out += '|CHOPHERE|'
|
59
|
+
end
|
60
|
+
|
61
|
+
def hash_to_tag_array(hash)
|
62
|
+
hash.collect {|(k,v)| {"Key" => k, "Value" => v} }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) 2012, SweetSpot Diabetes Care, Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
6
|
+
# may not use this work except in compliance with the License. You may
|
7
|
+
# obtain a copy of the License in the LICENSE file, or at:
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
14
|
+
# implied. See the License for the specific language governing
|
15
|
+
# permissions and limitations under the License.
|
16
|
+
|
17
|
+
#
|
18
|
+
|
19
|
+
module DrawCloud
|
20
|
+
class Vpc < Base
|
21
|
+
attr_accessor( :name,
|
22
|
+
:cidr )
|
23
|
+
|
24
|
+
def initialize(name, cidr, options={}, &block)
|
25
|
+
@name = name
|
26
|
+
@cidr = cidr
|
27
|
+
super(options, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def vpc
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def gateway!
|
35
|
+
if gateways.empty?
|
36
|
+
gateways << InternetGateway.new("InternetGateway", :parent => self)
|
37
|
+
end
|
38
|
+
gateways.first
|
39
|
+
end
|
40
|
+
|
41
|
+
def load_into_config(config)
|
42
|
+
config.cf_add_resource resource_name, self
|
43
|
+
super(config)
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_h
|
47
|
+
h = {
|
48
|
+
"Type" => "AWS::EC2::VPC",
|
49
|
+
"Properties" => {
|
50
|
+
"CidrBlock" => cidr,
|
51
|
+
"InstanceTenancy" => "default",
|
52
|
+
}
|
53
|
+
}
|
54
|
+
add_standard_properties(h)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module DrawCloud
|
2
|
+
class Vpc
|
3
|
+
include Base
|
4
|
+
|
5
|
+
attr_accessor :name, :cidr, :subnets, :route_tables, :gateways
|
6
|
+
|
7
|
+
def initialize(name, cidr, &block)
|
8
|
+
@name = name
|
9
|
+
@cidr = cidr
|
10
|
+
@subnets = []
|
11
|
+
@route_tables = []
|
12
|
+
@gateways = []
|
13
|
+
self.instance_exec(self, &block) if block
|
14
|
+
end
|
15
|
+
|
16
|
+
def gateway!
|
17
|
+
if gateways.empty?
|
18
|
+
gateways << InternetGateway.new("InternetGateway", :vpc => self)
|
19
|
+
end
|
20
|
+
gateways.first
|
21
|
+
end
|
22
|
+
|
23
|
+
def subnet(name, cidr, options={})
|
24
|
+
# collisioncheck
|
25
|
+
options[:vpc] = self
|
26
|
+
s = Subnet.new(name, cidr, options)
|
27
|
+
subnets << s
|
28
|
+
s
|
29
|
+
end
|
30
|
+
|
31
|
+
def route_table(name, options={}, &block)
|
32
|
+
options[:vpc] = self
|
33
|
+
r = RouteTable.new(name, options, &block)
|
34
|
+
route_tables << r
|
35
|
+
r
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_into_config(config)
|
39
|
+
config.cf_add_resource resource_name, self
|
40
|
+
@gateways.each {|g| g.load_into_config(config) }
|
41
|
+
@subnets.each {|g| g.load_into_config(config) }
|
42
|
+
@route_tables.each {|g| g.load_into_config(config) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_h
|
46
|
+
{
|
47
|
+
"Type" => "AWS::EC2::VPC",
|
48
|
+
"Properties" => {
|
49
|
+
"CidrBlock" => @cidr,
|
50
|
+
"InstanceTenancy" => "default",
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|