Class: VScripts::AWS::EC2
- Inherits:
-
Object
- Object
- VScripts::AWS::EC2
- Includes:
- Metadata
- Defined in:
- lib/vscripts/aws/ec2.rb
Overview
AWS Elastic Compute Cloud
Instance Attribute Summary collapse
- #ec2 ⇒ AWS::EC2 readonly
Instance Method Summary collapse
-
#all_tags ⇒ AWS::EC2::ResourceTagCollection
Tags collection.
-
#functional_instances ⇒ Object
@return Lists instances that are not terminated.
-
#initialize ⇒ EC2
constructor
Load AWS SDK for EC2.
-
#instance ⇒ Object
Get instance object.
-
#name ⇒ Object
Looks for the value of the ‘Name’ tag for the given instance.
-
#named_instances ⇒ Object
@return Lists instances that have a ‘Name’ tag.
-
#similar_instances ⇒ Object
@return The ‘Name’ tag value except the local instance.
-
#tags_without(list = []) ⇒ Object
Get a list of tags.
Methods included from Metadata
#check_instance, #ec2_instance?, #instance_id, #metadata_url, #public_hostname, #region, #zone
Constructor Details
#initialize ⇒ EC2
Load AWS SDK for EC2
14 15 16 |
# File 'lib/vscripts/aws/ec2.rb', line 14 def initialize @ec2 ||= ::AWS::EC2.new end |
Instance Attribute Details
Instance Method Details
#all_tags ⇒ AWS::EC2::ResourceTagCollection
Returns Tags collection.
28 29 30 |
# File 'lib/vscripts/aws/ec2.rb', line 28 def instance. end |
#functional_instances ⇒ Object
@return Lists instances that are not terminated
51 52 53 54 55 56 |
# File 'lib/vscripts/aws/ec2.rb', line 51 def functional_instances named_instances.map do |named_instance| named_instance if [:running, :shutting_down, :stopping, :stopped] .include?(named_instance.status) end end |
#instance ⇒ Object
Get instance object
22 23 24 25 |
# File 'lib/vscripts/aws/ec2.rb', line 22 def instance check_instance ec2.instances[instance_id] end |
#name ⇒ Object
Looks for the value of the ‘Name’ tag for the given instance
40 41 42 |
# File 'lib/vscripts/aws/ec2.rb', line 40 def name ['Name'] end |
#named_instances ⇒ Object
@return Lists instances that have a ‘Name’ tag
46 47 48 |
# File 'lib/vscripts/aws/ec2.rb', line 46 def named_instances ec2.instances.tagged('Name') end |
#similar_instances ⇒ Object
@return The ‘Name’ tag value except the local instance
59 60 61 62 63 64 65 66 |
# File 'lib/vscripts/aws/ec2.rb', line 59 def similar_instances check_instance functional_instances.map do |functional_instance| if functional_instance.id != instance_id functional_instance.['Name'] end end end |
#tags_without(list = []) ⇒ Object
Get a list of tags
33 34 35 36 37 |
# File 'lib/vscripts/aws/ec2.rb', line 33 def (list = []) all = list.each { |excluded| all.delete(excluded) } all end |