draw_cloud 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,56 @@
|
|
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 RouteTable < Base
|
21
|
+
attr_accessor :name, :routes
|
22
|
+
def initialize(name, options={}, &block)
|
23
|
+
@name = name
|
24
|
+
@routes = []
|
25
|
+
super(options, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def route_table
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def to(name, to_cidr, options={})
|
33
|
+
raise(Exeception, "No :via specified") unless options[:via]
|
34
|
+
@routes << RouteTableEntry.new(name, to_cidr, options[:via], options.merge(:parent => self))
|
35
|
+
end
|
36
|
+
|
37
|
+
def load_into_config(config)
|
38
|
+
config.cf_add_resource resource_name, self
|
39
|
+
@routes.each {|r| config.cf_add_resource(r.resource_name, r)}
|
40
|
+
super(config)
|
41
|
+
end
|
42
|
+
|
43
|
+
def resource_name
|
44
|
+
resource_style(name) + "Table"
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_h
|
48
|
+
h = {
|
49
|
+
"Type" => "AWS::EC2::RouteTable",
|
50
|
+
"Properties" => {}
|
51
|
+
}
|
52
|
+
h["Properties"]["VpcId"] = DrawCloud.ref(vpc) if vpc
|
53
|
+
add_standard_properties(h)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,59 @@
|
|
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 RouteTableEntry < Base
|
21
|
+
attr_accessor :name, :to, :via
|
22
|
+
def initialize(name, to, via, options={})
|
23
|
+
@name = name
|
24
|
+
@to = to
|
25
|
+
@via = via
|
26
|
+
super(options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def load_into_config(config)
|
30
|
+
# FIXME: emit error if no table attached
|
31
|
+
config.cf_add_resource resource_name, self
|
32
|
+
super(config)
|
33
|
+
end
|
34
|
+
|
35
|
+
def resource_name
|
36
|
+
route_table.resource_name + "To" + resource_style(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_h
|
40
|
+
h = {
|
41
|
+
"Type" => "AWS::EC2::Route",
|
42
|
+
"Properties" => {
|
43
|
+
"RouteTableId" => DrawCloud.ref(route_table),
|
44
|
+
"DestinationCidrBlock" => to,
|
45
|
+
}
|
46
|
+
}
|
47
|
+
if via.nil?
|
48
|
+
throw ArgumentError, "Route #{resource_name} requires :via"
|
49
|
+
elsif via.internet_gateway
|
50
|
+
h["Properties"]["GatewayId"] = DrawCloud.ref(via.internet_gateway)
|
51
|
+
# TODO: ["NetworkInterfaceId"]
|
52
|
+
elsif via.ec2_instance
|
53
|
+
h["Properties"]["InstanceId"] = DrawCloud.ref(via.ec2_instance)
|
54
|
+
end
|
55
|
+
|
56
|
+
add_standard_properties(h)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module DrawCloud
|
2
|
+
class RouteTableEntry
|
3
|
+
include Base
|
4
|
+
|
5
|
+
attr_accessor :name, :to, :via, :route_table
|
6
|
+
def initialize(name, to, via, options={})
|
7
|
+
@name = name
|
8
|
+
@to = to
|
9
|
+
@via = via
|
10
|
+
@route_table = options.fetch(:route_table, nil)
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_into_config(config)
|
14
|
+
# FIXME: emit error if no table attached
|
15
|
+
config.cf_add_resource resource_name, self
|
16
|
+
end
|
17
|
+
|
18
|
+
def resource_name
|
19
|
+
route_table.resource_name + "To" + resource_style(name)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_h
|
23
|
+
{
|
24
|
+
"Type" => "AWS::EC2::Route",
|
25
|
+
"Properties" => {
|
26
|
+
"RouteTableId" => route_table.ref,
|
27
|
+
"DestinationCdrBlock" => to,
|
28
|
+
"GatewayId" => via.ref,
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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 S3Bucket < Base
|
9
|
+
attr_accessor( :name )
|
10
|
+
|
11
|
+
def initialize(name, options={}, &block)
|
12
|
+
@name = name
|
13
|
+
@groups = []
|
14
|
+
@policies = []
|
15
|
+
super(options, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def iam_user
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_into_config(config)
|
23
|
+
config.cf_add_resource resource_name, self
|
24
|
+
super(config)
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_h
|
28
|
+
h = {
|
29
|
+
"Type" => "AWS::IAM::User",
|
30
|
+
"Properties" => {
|
31
|
+
}
|
32
|
+
}
|
33
|
+
h["Properties"]["Path"] = path if path
|
34
|
+
h["Properties"]["Groups"] = groups.collect {|g| DrawCloud.ref(g)} if (groups && !groups.empty?)
|
35
|
+
h["Properties"]["Policies"] = policies.collect {|p| DrawCloud.ref(p)} if (policies && !policies.empty?)
|
36
|
+
h["Properties"]["LoginProfile"] = login_profile if login_profile
|
37
|
+
h["Properties"]["LoginProfile"] = {"Password" => password} if (password && !h["Properties"].key?("LoginProfile"))
|
38
|
+
add_standard_properties(h)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,85 @@
|
|
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 SecurityGroup < Base
|
21
|
+
|
22
|
+
attr_accessor :name, :description, :ingress_rules
|
23
|
+
def initialize(name, description=nil, options={}, &block)
|
24
|
+
@name = name
|
25
|
+
@description = description || name.to_s
|
26
|
+
@ingress_rules = []
|
27
|
+
super(options, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def security_group
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def allow_security_group_in(protocol, source_security_group_id, from_port, to_port)
|
35
|
+
ingress_rules << {
|
36
|
+
"IpProtocol" => protocol.to_s,
|
37
|
+
"SourceSecurityGroupId" => DrawCloud.ref(source_security_group_id),
|
38
|
+
"FromPort" => from_port.to_s,
|
39
|
+
"ToPort" => to_port.to_s
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def allow_cidr_in(protocol, cidr, from_port, to_port)
|
44
|
+
ingress_rules << {
|
45
|
+
"IpProtocol" => protocol.to_s,
|
46
|
+
"CidrIp" => cidr,
|
47
|
+
"FromPort" => from_port.to_s,
|
48
|
+
"ToPort" => to_port.to_s
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def provides(services, options={})
|
53
|
+
end
|
54
|
+
|
55
|
+
def consumes(services, options={})
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_into_config(config)
|
59
|
+
config.cf_add_resource resource_name, self
|
60
|
+
super(config)
|
61
|
+
end
|
62
|
+
|
63
|
+
def resource_name
|
64
|
+
resource_style(name) + "SecurityGroup"
|
65
|
+
end
|
66
|
+
|
67
|
+
def check_validity
|
68
|
+
raise(ArgumentError, "Bad description for #{name.inspect} => #{description.inspect}. Must be [a-zA-Z0-9_ -]{0,255}") unless description =~ /^[a-zA-Z0-9_ -]{0,255}$/
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_h
|
72
|
+
check_validity
|
73
|
+
h = {
|
74
|
+
"Type" => "AWS::EC2::SecurityGroup",
|
75
|
+
"Properties" => {
|
76
|
+
"GroupDescription" => description,
|
77
|
+
"SecurityGroupIngress" => ingress_rules,
|
78
|
+
"SecurityGroupEgress" => [],
|
79
|
+
}
|
80
|
+
}
|
81
|
+
h["Properties"]["VpcId"] = DrawCloud.ref(vpc) if vpc
|
82
|
+
add_standard_properties(h)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module DrawCloud
|
2
|
+
class SecurityGroup
|
3
|
+
include Base
|
4
|
+
|
5
|
+
attr_accessor :vpc, :name, :description
|
6
|
+
def initialize(name, options={}, &block)
|
7
|
+
@name = name
|
8
|
+
@vpc = options.fetch(:vpc, nil)
|
9
|
+
@entries = []
|
10
|
+
self.instance_exec(self, &block) if block
|
11
|
+
end
|
12
|
+
|
13
|
+
def allow_in(protocol, cidr=:any, ports_or_types=[])
|
14
|
+
add_entry :allow, protocol, :ingress, cidr, ports_or_types
|
15
|
+
end
|
16
|
+
|
17
|
+
def allow_out(protocol, cidr=:any, ports_or_types=[])
|
18
|
+
add_entry :allow, protocol, :egress, cidr, ports_or_types
|
19
|
+
end
|
20
|
+
|
21
|
+
def deny_in(protocol, cidr=:any, ports_or_types=[])
|
22
|
+
add_entry :deny, protocol, :ingress, cidr, ports_or_types
|
23
|
+
end
|
24
|
+
|
25
|
+
def deny_out(protocol, cidr=:any, ports_or_types=[])
|
26
|
+
add_entry :deny, protocol, :egress, cidr, ports_or_types
|
27
|
+
end
|
28
|
+
|
29
|
+
def provides(service)
|
30
|
+
end
|
31
|
+
|
32
|
+
def consumes(service)
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_entry(action, protocol, direction, cidr, ports_or_types)
|
36
|
+
#entries.concat NetworkAclEntry.entries_from_spec(action, protocol, direction,
|
37
|
+
# cidr, ports_or_types, :network_acl => self)
|
38
|
+
end
|
39
|
+
private :add_entry
|
40
|
+
|
41
|
+
def load_into_config(config)
|
42
|
+
config.cf_add_resource resource_name, self
|
43
|
+
# ingress_index = 1
|
44
|
+
# egress_index = 1
|
45
|
+
# entries.each do |e|
|
46
|
+
# if e.outgoing?
|
47
|
+
# e.index = egress_index * 10
|
48
|
+
# egress_index += 1
|
49
|
+
# else
|
50
|
+
# e.index = ingress_index * 10
|
51
|
+
# ingress_index += 1
|
52
|
+
# end
|
53
|
+
|
54
|
+
# e.load_into_config(config)
|
55
|
+
# end
|
56
|
+
end
|
57
|
+
|
58
|
+
def resource_name
|
59
|
+
resource_style(name) + "SecurityGroup"
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_h
|
63
|
+
h = {
|
64
|
+
"Type" => "AWS::EC2::SecurityGroup",
|
65
|
+
"Properties" => {}
|
66
|
+
}
|
67
|
+
h["Properties"]["VpcId"] = vpc.ref if vpc
|
68
|
+
h
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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 Service
|
9
|
+
attr_accessor :name, :description
|
10
|
+
def initialize(name, description=nil, options={}, &block)
|
11
|
+
@name = name
|
12
|
+
@description = description || name.to_s
|
13
|
+
@entries = []
|
14
|
+
super(options, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def security_group
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def allow_in(protocol, cidr=:any, ports_or_types=[])
|
22
|
+
add_entry :allow, protocol, :ingress, cidr, ports_or_types
|
23
|
+
end
|
24
|
+
|
25
|
+
def allow_out(protocol, cidr=:any, ports_or_types=[])
|
26
|
+
add_entry :allow, protocol, :egress, cidr, ports_or_types
|
27
|
+
end
|
28
|
+
|
29
|
+
def provides(services, options={})
|
30
|
+
end
|
31
|
+
|
32
|
+
def consumes(services, options={})
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_entry(action, protocol, direction, cidr, ports_or_types)
|
36
|
+
#entries.concat NetworkAclEntry.entries_from_spec(action, protocol, direction,
|
37
|
+
# cidr, ports_or_types, :network_acl => self)
|
38
|
+
end
|
39
|
+
private :add_entry
|
40
|
+
|
41
|
+
def load_into_config(config)
|
42
|
+
config.cf_add_resource resource_name, self
|
43
|
+
super(config)
|
44
|
+
end
|
45
|
+
|
46
|
+
def resource_name
|
47
|
+
resource_style(name) + "SecurityGroup"
|
48
|
+
end
|
49
|
+
|
50
|
+
def check_validity
|
51
|
+
raise(ArgumentError, "Bad description for #{name.inspect} => #{description.inspect}. Must be [a-zA-Z0-9_ -]{0,255}") unless description =~ /^[a-zA-Z0-9_ -]{0,255}$/
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_h
|
55
|
+
check_validity
|
56
|
+
h = {
|
57
|
+
"Type" => "AWS::EC2::SecurityGroup",
|
58
|
+
"Properties" => {
|
59
|
+
"GroupDescription" => description,
|
60
|
+
"SecurityGroupIngress" => [],
|
61
|
+
"SecurityGroupEgress" => [],
|
62
|
+
}
|
63
|
+
}
|
64
|
+
h["Properties"]["VpcId"] = DrawCloud.ref(vpc) if vpc
|
65
|
+
# HACK HACK HACK
|
66
|
+
h["Properties"]["SecurityGroupIngress"] << {
|
67
|
+
"IpProtocol" => "-1",
|
68
|
+
"CidrIp" => "0.0.0.0/0",
|
69
|
+
"FromPort" => "-1",
|
70
|
+
"ToPort" => "-1",
|
71
|
+
}
|
72
|
+
add_standard_properties(h)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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 SimpleRef
|
21
|
+
attr_accessor :literal
|
22
|
+
def initialize(literal)
|
23
|
+
@literal = literal
|
24
|
+
end
|
25
|
+
|
26
|
+
def ref
|
27
|
+
{"Ref" => literal}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|