class EksCli::CloudFormation::Stack
Public Class Methods
await(stacks)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 19 def self.await(stacks) while pending(stacks) > 0 do Log.info "#{pending(stacks)} stacks out of #{stacks.count} are still being created" sleep 10 end stacks end
create(cluster_name, config)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 8 def self.create(cluster_name, config) Log.info "creating cloudformation stack #{config[:stack_name]}" begin stack_id = client(cluster_name).create_stack(config).stack_id rescue Aws::CloudFormation::Errors::AlreadyExistsException => e Log.warn "stack #{config[:stack_name]} already exists" stack_id = Aws::CloudFormation::Stack.new(config[:stack_name], client: client(cluster_name)).stack_id end new(cluster_name, stack_id) end
find(cluster_name, name)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 27 def self.find(cluster_name, name) new(cluster_name, Aws::CloudFormation::Stack.new(name, client: client(cluster_name)).stack_id) end
new(cluster_name, stack_id)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 31 def initialize(cluster_name, stack_id) @cluster_name = cluster_name @id = stack_id end
Private Class Methods
client(cluster_name)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 90 def self.client(cluster_name) CloudFormation::Client.get(cluster_name) end
pending(stacks)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 86 def self.pending(stacks) stacks.select(&:pending?).count end
Public Instance Methods
delete()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 36 def delete Log.info "deleting cloufdormation stack #{id}" client.delete_stack(stack_name: id) end
eks_cluster()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 51 def eks_cluster get_tag("eks-cluster") end
eks_worker?()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 47 def eks_worker? worker_tag end
id()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 41 def id; @id; end
node_instance_role_arn()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 55 def node_instance_role_arn output("NodeInstanceRole") end
node_instance_role_name()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 59 def node_instance_role_name node_instance_role_arn.split("/")[1] end
output(key)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 72 def output(key) stack.outputs.select {|a| a.output_key == key}.first.output_value end
outputs()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 76 def outputs stack.outputs end
pending?()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 43 def pending? status == "CREATE_IN_PROGRESS" end
reload()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 67 def reload stack(reload: true) self end
resource(key)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 80 def resource(key) Aws::CloudFormation::Stack.new(stack.stack_name, client: client).resource(key).physical_resource_id end
status()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 63 def status stack(reload: true).stack_status end
Private Instance Methods
client()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 94 def client self.class.client(@cluster_name) end
fetch()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 106 def fetch client.describe_stacks(stack_name: @id).stacks.first end
get_tag(k)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 110 def get_tag(k) tag = stack.tags.select {|t| t.key == k}.first tag.value if tag end
stack(reload: false)
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 98 def stack(reload: false) if reload @stack = fetch else @stack ||= fetch end end
worker_tag()
click to toggle source
# File lib/eks_cli/cloudformation/stack.rb, line 115 def worker_tag get_tag("eks-nodegroup") end