Class: DrawCloud::Base
- Inherits:
-
Object
- Object
- DrawCloud::Base
- Defined in:
- lib/draw_cloud/base.rb
Direct Known Subclasses
ASGroup, ASLaunchConfiguration, Configuration, EC2Instance, ElasticIp, IAMAccessKey, IAMPolicy, IAMUser, InternetGateway, Map, NetworkAcl, NetworkAclEntry, NetworkInterface, Output, Parameter, RDSInstance, RDSInstance::RDSSubnetGroup, RDSSecurityGroup, RouteTable, RouteTableEntry, SNSTopic, SecurityGroup, Subnet, Vpc, WaitHandle
Instance Attribute Summary collapse
-
#as_groups ⇒ Object
Returns the value of attribute as_groups.
-
#as_launch_configurations ⇒ Object
Returns the value of attribute as_launch_configurations.
-
#deletion_policy ⇒ Object
Returns the value of attribute deletion_policy.
-
#depends_on ⇒ Object
Returns the value of attribute depends_on.
-
#ec2_instances ⇒ Object
Returns the value of attribute ec2_instances.
-
#elastic_ips ⇒ Object
Returns the value of attribute elastic_ips.
-
#gateways ⇒ Object
Returns the value of attribute gateways.
-
#iam_access_keys ⇒ Object
Returns the value of attribute iam_access_keys.
-
#iam_policies ⇒ Object
Returns the value of attribute iam_policies.
-
#iam_users ⇒ Object
Returns the value of attribute iam_users.
-
#mappings ⇒ Object
Returns the value of attribute mappings.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#network_acls ⇒ Object
Returns the value of attribute network_acls.
-
#network_interfaces ⇒ Object
Returns the value of attribute network_interfaces.
-
#outputs ⇒ Object
Returns the value of attribute outputs.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#rdses ⇒ Object
Returns the value of attribute rdses.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#route_tables ⇒ Object
Returns the value of attribute route_tables.
-
#security_groups ⇒ Object
Returns the value of attribute security_groups.
-
#sns_topics ⇒ Object
Returns the value of attribute sns_topics.
-
#subnets ⇒ Object
Returns the value of attribute subnets.
-
#vpcs ⇒ Object
Returns the value of attribute vpcs.
-
#wait_handles ⇒ Object
Returns the value of attribute wait_handles.
Instance Method Summary collapse
- #[](attribute) ⇒ Object
-
#accessor ⇒ Object
Accessors (list below so grep works) def elastic_ip def internet_gateway def network_acl def rds def route_table def security_group def subnet def vpc.
- #add_standard_properties(hash) ⇒ Object
- #create_as_group(name, options = {}, &block) ⇒ Object
- #create_as_launch_configuration(name, options = {}, &block) ⇒ Object
- #create_ec2_instance(name, options = {}, &block) ⇒ Object
- #create_ec2_instance_template(name, options = {}, &block) ⇒ Object
- #create_elastic_ip(name, options = {}, &block) ⇒ Object
- #create_iam_access_key(name, options = {}, &block) ⇒ Object
- #create_iam_policy(name, options = {}, &block) ⇒ Object
- #create_iam_user(name, options = {}, &block) ⇒ Object
-
#create_mapping(name, map_by_function, values = {}) ⇒ Object
Definers.
- #create_network_acl(name, options = {}, &block) ⇒ Object
- #create_network_interface(name, options = {}, &block) ⇒ Object
- #create_output(name, options = {}, &block) ⇒ Object
- #create_parameter(name, type, options = {}, &block) ⇒ Object
- #create_rds(name, options = {}, &block) ⇒ Object
- #create_route_table(name, options = {}, &block) ⇒ Object
- #create_security_group(name, description = nil, options = {}, &block) ⇒ Object
- #create_service(name, options = {}, &block) ⇒ Object
- #create_sns_topic(name, options = {}, &block) ⇒ Object
- #create_subnet(name, cidr, options = {}, &block) ⇒ Object
- #create_vpc(name, cidr, options = {}, &block) ⇒ Object
- #create_wait_handle(name, timeout = nil, options = {}, &block) ⇒ Object
-
#initialize(options = {}, &block) ⇒ Base
constructor
A new instance of Base.
- #load_into_config(config) ⇒ Object
- #ref ⇒ Object
- #resource_name ⇒ Object
Methods included from Locations
Methods included from Utilities
#desplice, #fnbase64, #fngetatt, #fnjoin, #hash_to_tag_array, #region, #resource_style, #splice, #stack_name
Constructor Details
#initialize(options = {}, &block) ⇒ Base
Returns a new instance of Base.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/draw_cloud/base.rb', line 57 def initialize(={}, &block) @mappings = {} @parameters = {} @resources = {} @outputs = {} @subnets = [] @route_tables = [] @network_acls = [] @security_groups = [] @iam_users = [] @iam_policies = [] @iam_access_keys = [] @gateways = [] @rdses = [] @ec2_instances = [] @as_launch_configurations = [] @as_groups = [] @elastic_ips = [] @network_interfaces = [] @wait_handles = [] @vpcs = [] @sns_topics = [] @parent = .fetch(:parent, nil) self.instance_exec(self, &block) if block end |
Instance Attribute Details
#as_groups ⇒ Object
Returns the value of attribute as_groups.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def as_groups @as_groups end |
#as_launch_configurations ⇒ Object
Returns the value of attribute as_launch_configurations.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def as_launch_configurations @as_launch_configurations end |
#deletion_policy ⇒ Object
Returns the value of attribute deletion_policy.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def deletion_policy @deletion_policy end |
#depends_on ⇒ Object
Returns the value of attribute depends_on.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def depends_on @depends_on end |
#ec2_instances ⇒ Object
Returns the value of attribute ec2_instances.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def ec2_instances @ec2_instances end |
#elastic_ips ⇒ Object
Returns the value of attribute elastic_ips.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def elastic_ips @elastic_ips end |
#gateways ⇒ Object
Returns the value of attribute gateways.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def gateways @gateways end |
#iam_access_keys ⇒ Object
Returns the value of attribute iam_access_keys.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def iam_access_keys @iam_access_keys end |
#iam_policies ⇒ Object
Returns the value of attribute iam_policies.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def iam_policies @iam_policies end |
#iam_users ⇒ Object
Returns the value of attribute iam_users.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def iam_users @iam_users end |
#mappings ⇒ Object
Returns the value of attribute mappings.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def mappings @mappings end |
#metadata ⇒ Object
Returns the value of attribute metadata.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def @metadata end |
#network_acls ⇒ Object
Returns the value of attribute network_acls.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def network_acls @network_acls end |
#network_interfaces ⇒ Object
Returns the value of attribute network_interfaces.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def network_interfaces @network_interfaces end |
#outputs ⇒ Object
Returns the value of attribute outputs.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def outputs @outputs end |
#parameters ⇒ Object
Returns the value of attribute parameters.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def parameters @parameters end |
#parent ⇒ Object
Returns the value of attribute parent.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def parent @parent end |
#rdses ⇒ Object
Returns the value of attribute rdses.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def rdses @rdses end |
#resources ⇒ Object
Returns the value of attribute resources.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def resources @resources end |
#route_tables ⇒ Object
Returns the value of attribute route_tables.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def route_tables @route_tables end |
#security_groups ⇒ Object
Returns the value of attribute security_groups.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def security_groups @security_groups end |
#sns_topics ⇒ Object
Returns the value of attribute sns_topics.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def sns_topics @sns_topics end |
#subnets ⇒ Object
Returns the value of attribute subnets.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def subnets @subnets end |
#vpcs ⇒ Object
Returns the value of attribute vpcs.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def vpcs @vpcs end |
#wait_handles ⇒ Object
Returns the value of attribute wait_handles.
28 29 30 |
# File 'lib/draw_cloud/base.rb', line 28 def wait_handles @wait_handles end |
Instance Method Details
#[](attribute) ⇒ Object
112 113 114 |
# File 'lib/draw_cloud/base.rb', line 112 def [](attribute) fngetatt(self, attribute) end |
#accessor ⇒ Object
Accessors (list below so grep works) def elastic_ip def internet_gateway def network_acl def rds def route_table def security_group def subnet def vpc
250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/draw_cloud/base.rb', line 250 [:elastic_ip, :network_interface, :ec2_instance, :as_launch_configuration, :as_group, :internet_gateway, :network_acl, :rds, :route_table, :security_group, :subnet, :vpc, :iam_user, :iam_policy, :iam_access_key].each do |accessor| self.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def #{accessor}() if parent parent.#{accessor} else nil end end RUBY_EVAL end |
#add_standard_properties(hash) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/draw_cloud/base.rb', line 101 def add_standard_properties(hash) hash["DependsOn"] = DrawCloud.resource_name(depends_on) if depends_on hash["DeletionPolicy"] = DrawCloud.resource_style(deletion_policy) if deletion_policy hash["Metadata"] = DrawCloud.ref() unless .nil? hash end |
#create_as_group(name, options = {}, &block) ⇒ Object
217 218 219 220 221 |
# File 'lib/draw_cloud/base.rb', line 217 def create_as_group(name, ={}, &block) asg = ASGroup.new(name, .merge(:parent => self), &block) as_groups << asg asg end |
#create_as_launch_configuration(name, options = {}, &block) ⇒ Object
211 212 213 214 215 |
# File 'lib/draw_cloud/base.rb', line 211 def create_as_launch_configuration(name, ={}, &block) lc = ASLaunchConfiguration.new(name, .merge(:parent => self), &block) as_launch_configurations << lc lc end |
#create_ec2_instance(name, options = {}, &block) ⇒ Object
205 206 207 208 209 |
# File 'lib/draw_cloud/base.rb', line 205 def create_ec2_instance(name, ={}, &block) e = EC2Instance.new(name, .merge(:parent => self), &block) ec2_instances << e e end |
#create_ec2_instance_template(name, options = {}, &block) ⇒ Object
201 202 203 |
# File 'lib/draw_cloud/base.rb', line 201 def create_ec2_instance_template(name, ={}, &block) EC2InstanceTemplate.new(name, .merge(:parent => self), &block) end |
#create_elastic_ip(name, options = {}, &block) ⇒ Object
229 230 231 232 233 |
# File 'lib/draw_cloud/base.rb', line 229 def create_elastic_ip(name, ={}, &block) eip = ElasticIp.new(name, .merge(:parent => self), &block) elastic_ips << eip eip end |
#create_iam_access_key(name, options = {}, &block) ⇒ Object
189 190 191 192 193 |
# File 'lib/draw_cloud/base.rb', line 189 def create_iam_access_key(name, ={}, &block) a = IAMAccessKey.new(name, .merge(:parent => self), &block) iam_access_keys << a a end |
#create_iam_policy(name, options = {}, &block) ⇒ Object
183 184 185 186 187 |
# File 'lib/draw_cloud/base.rb', line 183 def create_iam_policy(name, ={}, &block) p = IAMPolicy.new(name, .merge(:parent => self), &block) iam_policies << p p end |
#create_iam_user(name, options = {}, &block) ⇒ Object
177 178 179 180 181 |
# File 'lib/draw_cloud/base.rb', line 177 def create_iam_user(name, ={}, &block) u = IAMUser.new(name, .merge(:parent => self), &block) iam_users << u u end |
#create_mapping(name, map_by_function, values = {}) ⇒ Object
Definers
118 119 120 121 122 |
# File 'lib/draw_cloud/base.rb', line 118 def create_mapping(name, map_by_function, values={}) m = Map.new(name, map_by_function, {:parent => self}, values) mappings[m.resource_name] = m m end |
#create_network_acl(name, options = {}, &block) ⇒ Object
165 166 167 168 169 |
# File 'lib/draw_cloud/base.rb', line 165 def create_network_acl(name, ={}, &block) a = NetworkAcl.new(name, .merge(:parent => self), &block) network_acls << a a end |
#create_network_interface(name, options = {}, &block) ⇒ Object
235 236 237 238 239 |
# File 'lib/draw_cloud/base.rb', line 235 def create_network_interface(name, ={}, &block) eni = NetworkInterface.new(name, .merge(:parent => self), &block) network_interfaces << eni eni end |
#create_output(name, options = {}, &block) ⇒ Object
124 125 126 127 128 |
# File 'lib/draw_cloud/base.rb', line 124 def create_output(name, ={}, &block) o = Output.new(name, .merge(:parent => self), &block) outputs[o.resource_name] = o o end |
#create_parameter(name, type, options = {}, &block) ⇒ Object
130 131 132 133 134 |
# File 'lib/draw_cloud/base.rb', line 130 def create_parameter(name, type, ={}, &block) p = Parameter.new(name, type, .merge(:parent => self), &block) parameters[p.resource_name] = p p end |
#create_rds(name, options = {}, &block) ⇒ Object
195 196 197 198 199 |
# File 'lib/draw_cloud/base.rb', line 195 def create_rds(name, ={}, &block) r = RDSInstance.new(name, .merge(:parent => self), &block) rdses << r r end |
#create_route_table(name, options = {}, &block) ⇒ Object
159 160 161 162 163 |
# File 'lib/draw_cloud/base.rb', line 159 def create_route_table(name, ={}, &block) r = RouteTable.new(name, .merge(:parent => self), &block) route_tables << r r end |
#create_security_group(name, description = nil, options = {}, &block) ⇒ Object
171 172 173 174 175 |
# File 'lib/draw_cloud/base.rb', line 171 def create_security_group(name, description=nil, ={}, &block) g = SecurityGroup.new(name, description, .merge(:parent => self), &block) security_groups << g g end |
#create_service(name, options = {}, &block) ⇒ Object
136 137 138 |
# File 'lib/draw_cloud/base.rb', line 136 def create_service(name, ={}, &block) # NOOP end |
#create_sns_topic(name, options = {}, &block) ⇒ Object
146 147 148 149 150 |
# File 'lib/draw_cloud/base.rb', line 146 def create_sns_topic(name, ={}, &block) s = SNSTopic.new(name, .merge(:parent => self), &block) sns_topics << s s end |
#create_subnet(name, cidr, options = {}, &block) ⇒ Object
152 153 154 155 156 157 |
# File 'lib/draw_cloud/base.rb', line 152 def create_subnet(name, cidr, ={}, &block) # collisioncheck s = Subnet.new(name, cidr, .merge(:parent => self), &block) subnets << s s end |
#create_vpc(name, cidr, options = {}, &block) ⇒ Object
140 141 142 143 144 |
# File 'lib/draw_cloud/base.rb', line 140 def create_vpc(name, cidr, ={}, &block) v = Vpc.new(name, cidr, .merge(:parent => self), &block) vpcs << v v end |
#create_wait_handle(name, timeout = nil, options = {}, &block) ⇒ Object
223 224 225 226 227 |
# File 'lib/draw_cloud/base.rb', line 223 def create_wait_handle(name, timeout=nil, ={}, &block) h = WaitHandle.new(name, timeout, .merge(:parent => self), &block) wait_handles << h h end |
#load_into_config(config) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/draw_cloud/base.rb', line 86 def load_into_config(config) [@mappings, @parameters, @resources, @outputs].each do |i| i.each {|k,v| v.load_into_config(config)} end [@gateways, @subnets, @route_tables, @network_acls, @security_groups, @iam_users, @iam_policies, @iam_access_keys, @rdses, @ec2_instances, @as_launch_configurations, @as_groups, @elastic_ips, @network_interfaces, @wait_handles, @vpcs, @sns_topics].each do |a| a.each {|g| g.load_into_config(config) } end end |
#ref ⇒ Object
108 109 110 |
# File 'lib/draw_cloud/base.rb', line 108 def ref {"Ref" => resource_name} end |
#resource_name ⇒ Object
97 98 99 |
# File 'lib/draw_cloud/base.rb', line 97 def resource_name resource_style(name) end |