neillturner / kitchen-cloudformation

A Test Kitchen Driver for Amazon AWS CloudFormation.
Other
16 stars 5 forks source link

kitchen-cloudformation will not allow for converge action #5

Closed sflaherty2009 closed 7 years ago

sflaherty2009 commented 7 years ago

Kitchen-cloudformation will only currently allow for create and destroy. In order to modify a stack you will have to first completely destroy it before rerunning the kitchen create command. If we could please have the functionality added to converge against stacks already created it would be appreciated.

neillturner commented 7 years ago
  1. we can add the update_state code below and then when you run create a second time it will do an update. 2, then we should allow converge kitchen function to call the create if stack doesn't exist or do an update if stack exists. 3, then the create kitchen function then then error message if the stack already exists.

    I’ve done a little digging and think I might know how to add this…. From taking a little from you and doing a little digging in AWS sdk this is what I have.

def update(state) stack = cf.get_stack(state[:stack_name]) if stack.nil? state.update_stack(:stack_name) else cf.update_stack(state[:stack_name]) begin stack = cf.get_stack(state[:stack_name]) while stack.stack_status == 'UPDATE_IN_PROGRESS' debug_stack_events(state[:stack_name]) info("CloudFormation waiting for stack <#{state[:stack_name]}> to be updated.....") sleep(30) stack = cf.get_stack(state[:stack_name]) end rescue info("CloudFormation stack <#{state[:stack_name]}> updated.") state.update_stack(:stack_name) return end display_stack_events(state[:stack_name]) error("CloudFormation stack <#{stack.stack_name}> failed to deleted.") end end

cd_client.rb-------------------------------------------

def update_stack(options) s.create_change_set(options) end

cloudformation.rb-----------------------------------

def update_stack stack_data = stack_generator.cf_stack_data info("Updating CloudFormation Stack #{stack_data[:stack_name]}") cf.update_stack(stack_data) end

neillturner commented 7 years ago

this is going to take a bit more work as i have to move it on to ruby AWS sdk v3 before i can use the create_change_set functionality. ok i have the create-change-set functionality working. need to add the update stack functionality.

neillturner commented 7 years ago

I have added this in version 1.4.0 See https://github.com/neillturner/cloudformation_repo for an example. I know my parameter error checking is not comprehensive and i'm not using all the parameters on the execute_change_set like stack_policy etc. So feel free to create PRs to enhance/fix that.