Class: PuppetEc2Enc::Instance
- Inherits:
-
Object
- Object
- PuppetEc2Enc::Instance
- Defined in:
- lib/puppet_ec2_enc/instance.rb
Instance Attribute Summary collapse
-
#ec2 ⇒ Object
Returns the value of attribute ec2.
-
#region ⇒ Object
Returns the value of attribute region.
Class Method Summary collapse
Instance Method Summary collapse
- #by_private_dns(fqdn) ⇒ Object
-
#initialize(opts = {}) ⇒ Instance
constructor
A new instance of Instance.
Constructor Details
#initialize(opts = {}) ⇒ Instance
Returns a new instance of Instance.
7 8 9 10 |
# File 'lib/puppet_ec2_enc/instance.rb', line 7 def initialize(opts = {}) @region = opts[:region] || nil @ec2 = Aws::EC2::Client.new(region: region) end |
Instance Attribute Details
#ec2 ⇒ Object
Returns the value of attribute ec2.
5 6 7 |
# File 'lib/puppet_ec2_enc/instance.rb', line 5 def ec2 @ec2 end |
#region ⇒ Object
Returns the value of attribute region.
5 6 7 |
# File 'lib/puppet_ec2_enc/instance.rb', line 5 def region @region end |
Class Method Details
.client(region) ⇒ Object
12 13 14 |
# File 'lib/puppet_ec2_enc/instance.rb', line 12 def self.client(region) self.new(region: region) end |
Instance Method Details
#by_private_dns(fqdn) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet_ec2_enc/instance.rb', line 16 def by_private_dns(fqdn) filter_hash = { name: 'private-dns-name', values: [fqdn] } reservations = filtered_search(filter_hash) raise RuntimeError.new( "Did not find EC2 instance named #{fqdn}!" ) if reservations.nil? raise RuntimeError.new( "Somehow found more than one EC2 instance named #{fqdn}!" ) if reservations.count > 1 return reservations[0].instances[0] end |