Class: Ec2ssh::Ec2Instances
- Inherits:
-
Object
- Object
- Ec2ssh::Ec2Instances
- Defined in:
- lib/ec2ssh/ec2_instances.rb
Instance Attribute Summary collapse
-
#aws_keys ⇒ Object
readonly
Returns the value of attribute aws_keys.
-
#ec2s ⇒ Object
readonly
Returns the value of attribute ec2s.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(aws_keys, regions) ⇒ Ec2Instances
constructor
A new instance of Ec2Instances.
- #instances(key_name) ⇒ Object
- #make_ec2s ⇒ Object
Constructor Details
#initialize(aws_keys, regions) ⇒ Ec2Instances
Returns a new instance of Ec2Instances.
7 8 9 10 |
# File 'lib/ec2ssh/ec2_instances.rb', line 7 def initialize(aws_keys, regions) @aws_keys = aws_keys @regions = regions end |
Instance Attribute Details
#aws_keys ⇒ Object (readonly)
Returns the value of attribute aws_keys.
5 6 7 |
# File 'lib/ec2ssh/ec2_instances.rb', line 5 def aws_keys @aws_keys end |
#ec2s ⇒ Object (readonly)
Returns the value of attribute ec2s.
5 6 7 |
# File 'lib/ec2ssh/ec2_instances.rb', line 5 def ec2s @ec2s end |
Class Method Details
.expand_profile_name_to_credential(profile_name) ⇒ Object
38 39 40 41 |
# File 'lib/ec2ssh/ec2_instances.rb', line 38 def self.(profile_name) provider = AWS::Core::CredentialProviders::SharedCredentialFileProvider.new(profile_name: profile_name) provider.credentials end |
Instance Method Details
#instances(key_name) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/ec2ssh/ec2_instances.rb', line 29 def instances(key_name) @regions.map {|region| ec2s[key_name][region].instances. filter('instance-state-name', 'running'). to_a. sort_by {|ins| ins.['Name'].to_s } }.flatten end |
#make_ec2s ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ec2ssh/ec2_instances.rb', line 12 def make_ec2s AWS.start_memoizing _ec2s = {} aws_keys.each do |name, key| _ec2s[name] = {} @regions.each do |region| = key.merge ec2_region: region _ec2s[name][region] = AWS::EC2.new end end _ec2s end |