Class: DrawCloud::ElasticIp::ElasticIpAssociation
- Inherits:
-
Object
- Object
- DrawCloud::ElasticIp::ElasticIpAssociation
- Defined in:
- lib/draw_cloud/elastic_ip.rb
Instance Attribute Summary collapse
-
#elastic_ip ⇒ Object
Returns the value of attribute elastic_ip.
-
#instance ⇒ Object
Returns the value of attribute instance.
-
#vpc ⇒ Object
Returns the value of attribute vpc.
Instance Method Summary collapse
-
#initialize(elastic_ip, instance, vpc) ⇒ ElasticIpAssociation
constructor
A new instance of ElasticIpAssociation.
- #resource_name ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(elastic_ip, instance, vpc) ⇒ ElasticIpAssociation
Returns a new instance of ElasticIpAssociation.
23 24 25 26 27 |
# File 'lib/draw_cloud/elastic_ip.rb', line 23 def initialize(elastic_ip, instance, vpc) @elastic_ip = elastic_ip @instance = instance @vpc = vpc end |
Instance Attribute Details
#elastic_ip ⇒ Object
Returns the value of attribute elastic_ip.
22 23 24 |
# File 'lib/draw_cloud/elastic_ip.rb', line 22 def elastic_ip @elastic_ip end |
#instance ⇒ Object
Returns the value of attribute instance.
22 23 24 |
# File 'lib/draw_cloud/elastic_ip.rb', line 22 def instance @instance end |
#vpc ⇒ Object
Returns the value of attribute vpc.
22 23 24 |
# File 'lib/draw_cloud/elastic_ip.rb', line 22 def vpc @vpc end |
Instance Method Details
#resource_name ⇒ Object
29 30 31 |
# File 'lib/draw_cloud/elastic_ip.rb', line 29 def resource_name elastic_ip.resource_name + "Association" end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/draw_cloud/elastic_ip.rb', line 33 def to_h h = { "Type" => "AWS::EC2::EIPAssociation", "Properties" => { }, } if instance.ec2_instance h["Properties"]["InstanceId"] = DrawCloud.ref(instance) elsif instance.network_interface h["Properties"]["NetworkInterfaceId"] = DrawCloud.ref(instance) else raise ArgumentError, "Unknown instance or network interface type #{instance.inspect}" end if vpc case elastic_ip when DrawCloud::ElasticIp h["Properties"]["AllocationId"] = DrawCloud.ref(elastic_ip[:allocation_id]) else h["Properties"]["AllocationId"] = DrawCloud.ref(elastic_ip) end else h["Properties"]["EIP"] = DrawCloud.ref(elastic_ip) end h end |