class Dynamocli::Table::CloudformationTable
Constants
- CLOUDFORMARTION
- LOGGER
Attributes
cloudformation[R]
logger[R]
stack[R]
table_name[R]
Public Class Methods
new(table_name:, stack:, cloudformation: nil, logger: nil)
click to toggle source
# File lib/dynamocli/table/cloudformation_table.rb, line 8 def initialize(table_name:, stack:, cloudformation: nil, logger: nil) @table_name = table_name @stack = stack @cloudformation = cloudformation || CLOUDFORMARTION.new @logger = logger || LOGGER.new end
Public Instance Methods
alert_message_before_continue()
click to toggle source
# File lib/dynamocli/table/cloudformation_table.rb, line 15 def alert_message_before_continue "You're going to deploy and redeploy your #{stack.name} stack to drop and recreate the #{@table_name} table!" end
erase()
click to toggle source
# File lib/dynamocli/table/cloudformation_table.rb, line 19 def erase deploy_stack_without_the_table wait_for_deployment_to_complete deploy_stack_with_the_original_template end
Private Instance Methods
deploy_stack_with_the_original_template()
click to toggle source
# File lib/dynamocli/table/cloudformation_table.rb, line 59 def deploy_stack_with_the_original_template logger.info("Deploying the stack with the #{table_name} table") cloudformation.update_stack( stack_name: stack.name, template_body: stack.original_template.to_json, parameters: stack.parameters.map(&:to_h), capabilities: stack.capabilities, role_arn: stack.role_arn, rollback_configuration: stack.rollback_configuration.to_h, stack_policy_body: stack.policy_body, notification_arns: stack.notification_arns, tags: stack.tags.map(&:to_h) ) logger.success("Stack deployed with the #{table_name} table") end
deploy_stack_without_the_table()
click to toggle source
# File lib/dynamocli/table/cloudformation_table.rb, line 33 def deploy_stack_without_the_table logger.info("Deploying the stack without the #{table_name} table") cloudformation.update_stack( stack_name: stack.name, template_body: stack.template_without_table.to_json, parameters: stack.parameters.map(&:to_h), capabilities: stack.capabilities, role_arn: stack.role_arn, rollback_configuration: stack.rollback_configuration.to_h, stack_policy_body: stack.policy_body, notification_arns: stack.notification_arns, tags: stack.tags.map(&:to_h) ) logger.success("Stack deployed without the #{table_name} table") end
wait_for_deployment_to_complete()
click to toggle source
# File lib/dynamocli/table/cloudformation_table.rb, line 51 def wait_for_deployment_to_complete waiting_seconds = 0 while stack.deploying? logger.info("Waiting for deployment to complete") sleep waiting_seconds += 1 end end