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.
Files changed (62) hide show
  1. data/README.md +22 -0
  2. data/lib/draw_cloud.rb +75 -0
  3. data/lib/draw_cloud/as_group.rb +104 -0
  4. data/lib/draw_cloud/as_group.rb~ +54 -0
  5. data/lib/draw_cloud/as_launch_configuration.rb +71 -0
  6. data/lib/draw_cloud/as_launch_configuration.rb~ +50 -0
  7. data/lib/draw_cloud/base.rb +264 -0
  8. data/lib/draw_cloud/base64_func.rb +30 -0
  9. data/lib/draw_cloud/configuration.rb +61 -0
  10. data/lib/draw_cloud/configuration.rb~ +64 -0
  11. data/lib/draw_cloud/ec2_instance.rb +141 -0
  12. data/lib/draw_cloud/ec2_instance.rb~ +78 -0
  13. data/lib/draw_cloud/ec2_instance_template.rb +29 -0
  14. data/lib/draw_cloud/ec2_instance_template.rb~ +36 -0
  15. data/lib/draw_cloud/elastic_ip.rb +97 -0
  16. data/lib/draw_cloud/elastic_ip.rb~ +19 -0
  17. data/lib/draw_cloud/get_att_func.rb +31 -0
  18. data/lib/draw_cloud/get_att_func.rb~ +19 -0
  19. data/lib/draw_cloud/iam_access_key.rb +53 -0
  20. data/lib/draw_cloud/iam_access_key.rb~ +43 -0
  21. data/lib/draw_cloud/iam_policy.rb +71 -0
  22. data/lib/draw_cloud/iam_policy.rb~ +41 -0
  23. data/lib/draw_cloud/iam_user.rb +53 -0
  24. data/lib/draw_cloud/iam_user.rb~ +44 -0
  25. data/lib/draw_cloud/internet_gateway.rb +66 -0
  26. data/lib/draw_cloud/join_func.rb +31 -0
  27. data/lib/draw_cloud/join_func.rb~ +24 -0
  28. data/lib/draw_cloud/locations.rb +25 -0
  29. data/lib/draw_cloud/locations.rb~ +53 -0
  30. data/lib/draw_cloud/map.rb +65 -0
  31. data/lib/draw_cloud/network_acl.rb +91 -0
  32. data/lib/draw_cloud/network_acl.rb~ +36 -0
  33. data/lib/draw_cloud/network_acl_entry.rb +110 -0
  34. data/lib/draw_cloud/network_acl_entry.rb~ +36 -0
  35. data/lib/draw_cloud/network_interface.rb +71 -0
  36. data/lib/draw_cloud/network_interface.rb~ +46 -0
  37. data/lib/draw_cloud/output.rb +38 -0
  38. data/lib/draw_cloud/output.rb~ +39 -0
  39. data/lib/draw_cloud/parameter.rb +58 -0
  40. data/lib/draw_cloud/parameter.rb~ +30 -0
  41. data/lib/draw_cloud/rds_instance.rb +117 -0
  42. data/lib/draw_cloud/rds_security_group.rb +57 -0
  43. data/lib/draw_cloud/route_table.rb +56 -0
  44. data/lib/draw_cloud/route_table_entry.rb +59 -0
  45. data/lib/draw_cloud/route_table_entry.rb~ +33 -0
  46. data/lib/draw_cloud/s3_bucket.rb~ +41 -0
  47. data/lib/draw_cloud/security_group.rb +85 -0
  48. data/lib/draw_cloud/security_group.rb~ +71 -0
  49. data/lib/draw_cloud/service.rb~ +75 -0
  50. data/lib/draw_cloud/simple_ref.rb +30 -0
  51. data/lib/draw_cloud/simple_ref.rb~ +17 -0
  52. data/lib/draw_cloud/sns_topic.rb +58 -0
  53. data/lib/draw_cloud/sns_topic.rb~ +39 -0
  54. data/lib/draw_cloud/subnet.rb +104 -0
  55. data/lib/draw_cloud/subnet.rb~ +56 -0
  56. data/lib/draw_cloud/utilities.rb +65 -0
  57. data/lib/draw_cloud/version.rb +3 -0
  58. data/lib/draw_cloud/vpc.rb +57 -0
  59. data/lib/draw_cloud/vpc.rb~ +55 -0
  60. data/lib/draw_cloud/wait_handle.rb +78 -0
  61. data/lib/draw_cloud/wait_handle.rb~ +10 -0
  62. metadata +195 -0
@@ -0,0 +1,71 @@
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 NetworkInterface < Base
21
+ attr_accessor(:name, :description, :tags, :source_dest_check, :group_set, :subnet_id, :private_ip_address)
22
+ alias :subnet :subnet_id
23
+ alias :subnet= :subnet_id=
24
+ alias :security_groups :group_set
25
+ alias :security_groups= :group_set=
26
+ def initialize(name, options={}, &block)
27
+ @name = name
28
+ @tags = {}
29
+ super(options, &block)
30
+ end
31
+
32
+ def network_interface
33
+ self
34
+ end
35
+
36
+ def load_into_config(config)
37
+ config.cf_add_resource resource_name, self
38
+ super(config)
39
+ end
40
+
41
+ def resource_name
42
+ resource_style(name) + "ElasticNetworkInterface"
43
+ end
44
+
45
+ def elastic_ip=(eip)
46
+ eip.instance_id = self
47
+ end
48
+
49
+ def default_tags
50
+ {"Name" => resource_style(name)}
51
+ end
52
+
53
+ def to_h
54
+ h = {
55
+ "Type" => "AWS::EC2::NetworkInterface",
56
+ "Properties" => {
57
+ "SubnetId" => DrawCloud.ref(subnet_id)
58
+ }
59
+ }
60
+ p = h["Properties"]
61
+ p["Description"] = description unless description.nil?
62
+ p["GroupSet"] = group_set.collect {|g| DrawCloud.ref(g)} unless (group_set.nil? || group_set.empty?)
63
+ p["PrivateIpAddress"] = private_ip_address unless private_ip_address.nil?
64
+ p["SourceDestCheck"] = source_dest_check unless source_dest_check.nil?
65
+ all_tags = default_tags.merge(tags)
66
+ p["Tags"] = hash_to_tag_array(all_tags) unless all_tags.empty?
67
+ add_standard_properties(h)
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,46 @@
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 ElasticIp < Base
9
+ attr_accessor(:name, :description, :tags, :source_dest_check, :group_set, :subnet_id, :private_ip_address)
10
+ def initialize(name, options={}, &block)
11
+ @name = name
12
+ @domain = options.fetch(:domain, nil)
13
+ @instance_id = options.fetch(:instance_id, nil)
14
+ super(options, &block)
15
+ end
16
+
17
+ def elastic_ip
18
+ self
19
+ end
20
+
21
+ def association
22
+ ElasticIpAssociation.new(self, instance_id, vpc)
23
+ end
24
+
25
+ def load_into_config(config)
26
+ config.cf_add_resource resource_name, self
27
+ config.cf_add_resource(association.resource_name, association) if instance_id
28
+ super(config)
29
+ end
30
+
31
+ def resource_name
32
+ resource_style(name) + "EIP"
33
+ end
34
+
35
+ def to_h
36
+ h = {
37
+ "Type" => "AWS::EC2::EIP",
38
+ "Properties" => {}
39
+ }
40
+ h["Properties"]["Domain"] = domain unless domain.nil?
41
+ h["Properties"]["Domain"] = "vpc" if (domain.nil? && vpc)
42
+ add_standard_properties(h)
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,38 @@
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 Output < Base
21
+ attr_accessor :name, :description, :value
22
+ def initialize(name, options={}, &block)
23
+ @name = name
24
+ super(options, &block)
25
+ end
26
+
27
+ def load_into_config(config)
28
+ config.cf_add_output resource_name, self
29
+ super(config)
30
+ end
31
+
32
+ def to_h
33
+ h = {"Value" => DrawCloud.ref(value)}
34
+ h["Description"] = description if description
35
+ h
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,39 @@
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 Output
9
+ include Base
10
+
11
+ attr_accessor :name, :value
12
+ def initialize(name, map_by_function, values={})
13
+ @name = name
14
+ @map_by_function = map_by_function
15
+ @values = values
16
+ end
17
+
18
+ def [](key)
19
+ MapLookup.new(self, key)
20
+ end
21
+
22
+ def function_resource
23
+ case map_by_function
24
+ when :map_by_region
25
+ {"Ref" => "AWS::Region"}
26
+ else
27
+ raise ArgumentError, "Unknown map function #{map_by_function}"
28
+ end
29
+ end
30
+
31
+ def load_into_config(config)
32
+ config.cf_add_mapping resource_name, self
33
+ end
34
+
35
+ def to_h
36
+ values
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,58 @@
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 Parameter < Base
21
+ attr_accessor(:name, :description,
22
+ :allowed_pattern,
23
+ :type, :default, :no_echo,
24
+ :allowed_values, :max_length, :min_length,
25
+ :max_value, :min_value,
26
+ :constraint_description)
27
+ def initialize(name, type, options={}, &block)
28
+ @name = name
29
+ @type = type
30
+ super(options, &block)
31
+ end
32
+
33
+ def load_into_config(config)
34
+ config.cf_add_parameter resource_name, self
35
+ super(config)
36
+ end
37
+
38
+ def to_h
39
+ h = {"Type" => DrawCloud.ref(type)}
40
+ [:type, :default, :no_echo,
41
+ :allowed_values, :max_length, :min_length,
42
+ :max_value, :min_value,
43
+ :constraint_description].each do |prop_str|
44
+ prop = prop_str.intern
45
+ h[resource_style(prop)] = DrawCloud.ref(self.send(prop)) unless self.send(prop).nil?
46
+ end
47
+ if !allowed_pattern.nil?
48
+ h["AllowedPattern"] = case allowed_pattern
49
+ when Regexp
50
+ allowed_pattern.source
51
+ else
52
+ allowed_pattern.to_s
53
+ end
54
+ end
55
+ h
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,30 @@
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 Parameter < Base
9
+ attr_accessor(:name, :description,
10
+ :type, :default, :no_echo,
11
+ :allowed_values, :allowed_pattern, :max_length, :min_length,
12
+ :max_value, :min_value,
13
+ :constraint_description)
14
+ def initialize(name, options={}, &block)
15
+ @name = name
16
+ super(options, &block)
17
+ end
18
+
19
+ def load_into_config(config)
20
+ config.cf_add_output resource_name, self
21
+ super(config)
22
+ end
23
+
24
+ def to_h
25
+ h = {"Value" => DrawCloud.ref(value)}
26
+ h["Description"] = description if description
27
+ h
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,117 @@
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 RDSInstance < Base
21
+ class RDSSubnetGroup < Base
22
+ attr_accessor :rds, :rds_subnets
23
+ def initialize(rds, rds_subnets)
24
+ @rds_subnets = rds_subnets
25
+ @rds = rds
26
+ end
27
+
28
+ def resource_name
29
+ rds.resource_name + "SubnetGroup"
30
+ end
31
+
32
+ def to_h
33
+ { "Type" => "AWS::RDS::DBSubnetGroup",
34
+ "Properties" => {
35
+ "DBSubnetGroupDescription" => "Security group for RDS" + DrawCloud.resource_name(rds),
36
+ "SubnetIds" => rds_subnets.collect { |s| DrawCloud.ref(s) },
37
+ }
38
+ }
39
+ end
40
+ end
41
+
42
+ attr_accessor( :name,
43
+ :allocated_storage,
44
+ :db_instance_class,
45
+ :master_username,
46
+ :master_user_password,
47
+ :db_security_groups,
48
+ :engine,
49
+ :engine_version,
50
+ :multi_az,
51
+ :rds_subnets,
52
+ :db_snapshot_identifier,
53
+ :auto_minor_version_upgrade,
54
+ :backup_retention_period,
55
+ :iops )
56
+ alias :instance_class :db_instance_class
57
+ alias :instance_class= :db_instance_class=
58
+ alias :master_password :master_user_password
59
+ alias :master_password= :master_user_password=
60
+ def initialize(name, options={}, &block)
61
+ @name = name
62
+ @db_security_groups = []
63
+ @rds_subnets = []
64
+ super(options, &block)
65
+ end
66
+
67
+ def rds
68
+ self
69
+ end
70
+
71
+ def load_into_config(config)
72
+ config.cf_add_resource resource_name, self
73
+ db_security_groups.each {|g| g.load_into_config(config) }
74
+ unless rds_subnets.empty?
75
+ config.cf_add_resource subnet_group.resource_name, subnet_group
76
+ end
77
+ super(config)
78
+ end
79
+
80
+ def resource_name
81
+ resource_style(name) + "RDS"
82
+ end
83
+
84
+ def subnet_group
85
+ RDSSubnetGroup.new(self, rds_subnets)
86
+ end
87
+
88
+ def db_security_group(name, description, options={}, &block)
89
+ d = RDSSecurityGroup.new(name, description, options.merge(:parent => self), &block)
90
+ db_security_groups << d
91
+ d
92
+ end
93
+
94
+ def to_h
95
+ h = {
96
+ "Type" => "AWS::RDS::DBInstance",
97
+ "Properties" => {
98
+ "DBSecurityGroups" => db_security_groups.collect { |g| DrawCloud.ref(g)},
99
+ "AllocatedStorage" => DrawCloud.ref(allocated_storage),
100
+ "Engine" => DrawCloud.ref(engine),
101
+ "DBInstanceClass" => DrawCloud.ref(db_instance_class),
102
+ "MasterUsername" => DrawCloud.ref(master_username),
103
+ "MasterUserPassword" => DrawCloud.ref(master_user_password),
104
+ }
105
+ }
106
+ p = h["Properties"]
107
+ p["DBSnapshotIdentifier"] = DrawCloud.ref(db_snapshot_identifier) if db_snapshot_identifier
108
+ p["MultiAZ"] = multi_az unless multi_az.nil?
109
+ p["EngineVersion"] = DrawCloud.ref(engine_version) unless engine_version.nil?
110
+ p["Iops"] = DrawCloud.ref(iops) if iops
111
+ p["DBSubnetGroupName"] = DrawCloud.ref(subnet_group) unless rds_subnets.empty?
112
+ p["AutoMinorVersionUpgrade"] = DrawCloud.ref(auto_minor_version_upgrade) unless auto_minor_version_upgrade.nil?
113
+ p["BackupRetentionPeriod"] = DrawCloud.ref(backup_retention_period) unless backup_retention_period.nil?
114
+ add_standard_properties(h)
115
+ end
116
+ end
117
+ 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 RDSSecurityGroup < Base
21
+ attr_accessor :name, :description, :allows
22
+ def initialize(name, description, options={}, &block)
23
+ @name = name
24
+ @description = description
25
+ @allows = []
26
+ super(options, &block)
27
+ end
28
+
29
+ def allow_in(designator)
30
+ allows << designator
31
+ end
32
+
33
+ def load_into_config(config)
34
+ config.cf_add_resource resource_name, self
35
+ super(config)
36
+ end
37
+
38
+ def resource_name
39
+ DrawCloud.resource_name(rds) + DrawCloud.resource_name(name) + "SG"
40
+ end
41
+
42
+ def to_h
43
+ h = {
44
+ "Type" => "AWS::RDS::DBSecurityGroup",
45
+ "Properties" => {
46
+ "GroupDescription" => description,
47
+ "DBSecurityGroupIngress" => [],
48
+ }
49
+ }
50
+ h["Properties"]["EC2VpcId"] = DrawCloud.ref(vpc) if vpc
51
+ h["Properties"]["DBSecurityGroupIngress"] << {
52
+ "CIDRIP" => "0.0.0.0/0"
53
+ }
54
+ h
55
+ end
56
+ end
57
+ end