Class: Stax::Aws::Ec2

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

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.clientObject



7
8
9
# File 'lib/stax/aws/ec2.rb', line 7

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

.create_tags(opt) ⇒ Object

tag AMIs



25
26
27
# File 'lib/stax/aws/ec2.rb', line 25

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

.images(opt = {}) ⇒ Object

list AMIs



20
21
22
# File 'lib/stax/aws/ec2.rb', line 20

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

.instances(name) ⇒ Object

return instances tagged by stack with name



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

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