Class: Cloudpatrol::Task::CloudFormation

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudpatrol/task/cloud_formation.rb

Instance Method Summary collapse

Constructor Details

#initialize(cred) ⇒ CloudFormation

Returns a new instance of CloudFormation.



6
7
8
# File 'lib/cloudpatrol/task/cloud_formation.rb', line 6

def initialize cred
  @gate = ::AWS::CloudFormation.new(cred)
end

Instance Method Details

#clean_stacks(allowed_age) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/cloudpatrol/task/cloud_formation.rb', line 10

def clean_stacks allowed_age
  deleted = []
  @gate.stacks.each do |stack|
    if (Time.now - stack.creation_time).to_i > allowed_age.days
      deleted << stack.inspect
      stack.delete
    end
  end
  deleted
end