Class: Stax::Aws::Ec2

Inherits:
Sdk
  • Object
show all
Defined in:
lib/stax/aws/ec2.rb

Constant Summary

Constants inherited from Sdk

Sdk::RETRY_LIMIT

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.clientObject



9
10
11
# File 'lib/stax/aws/ec2.rb', line 9

def client
  @_client ||= ::Aws::EC2::Client.new
end

.create_tags(opt) ⇒ Object

tag AMIs



27
28
29
# File 'lib/stax/aws/ec2.rb', line 27

def create_tags(opt)
  client.create_tags(opt)
end

.images(opt = {}) ⇒ Object

list AMIs



22
23
24
# File 'lib/stax/aws/ec2.rb', line 22

def images(opt = {})
  client.describe_images(opt).images.sort_by(&:creation_date)
end

.instances(name) ⇒ Object

return instances tagged by stack with name



14
15
16
17
18
19
# File 'lib/stax/aws/ec2.rb', line 14

def instances(name)
  filter = {name: 'tag:aws:cloudformation:stack-name', values: [name]}
  paginate(:reservations) do |token|
    client.describe_instances(filters: [filter], next_token: token)
  end.map(&:instances).flatten
end