Class: EksCli::CloudFormation::Stack
- Inherits:
-
Object
- Object
- EksCli::CloudFormation::Stack
- Defined in:
- lib/eks_cli/cloudformation/stack.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delete ⇒ Object
- #eks_cluster ⇒ Object
- #eks_worker? ⇒ Boolean
- #id ⇒ Object
-
#initialize(cluster_name, stack_id) ⇒ Stack
constructor
A new instance of Stack.
- #node_instance_role_arn ⇒ Object
- #node_instance_role_name ⇒ Object
- #output(key) ⇒ Object
- #outputs ⇒ Object
- #pending? ⇒ Boolean
- #reload ⇒ Object
- #resource(key) ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(cluster_name, stack_id) ⇒ Stack
Returns a new instance of Stack.
31 32 33 34 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 31 def initialize(cluster_name, stack_id) @cluster_name = cluster_name @id = stack_id end |
Class Method Details
.await(stacks) ⇒ Object
19 20 21 22 23 24 25 |
# 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) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# 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) ⇒ Object
27 28 29 |
# 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 |
Instance Method Details
#delete ⇒ Object
36 37 38 39 |
# 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 ⇒ Object
51 52 53 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 51 def eks_cluster get_tag("eks-cluster") end |
#eks_worker? ⇒ Boolean
47 48 49 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 47 def eks_worker? worker_tag end |
#id ⇒ Object
41 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 41 def id; @id; end |
#node_instance_role_arn ⇒ Object
55 56 57 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 55 def node_instance_role_arn output("NodeInstanceRole") end |
#node_instance_role_name ⇒ Object
59 60 61 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 59 def node_instance_role_name node_instance_role_arn.split("/")[1] end |
#output(key) ⇒ Object
72 73 74 |
# 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 ⇒ Object
76 77 78 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 76 def outputs stack.outputs end |
#pending? ⇒ Boolean
43 44 45 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 43 def pending? status == "CREATE_IN_PROGRESS" end |
#reload ⇒ Object
67 68 69 70 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 67 def reload stack(reload: true) self end |
#resource(key) ⇒ Object
80 81 82 |
# 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 ⇒ Object
63 64 65 |
# File 'lib/eks_cli/cloudformation/stack.rb', line 63 def status stack(reload: true).stack_status end |