def step_impl(context, stack_name, desired_status): full_name = get_cloudformation_stack_name(context, stack_name) status = get_stack_status(context, full_name) if status != desired_status: delete_stack(context, full_name) if desired_status == "CREATE_COMPLETE": body = read_template_file(context, "valid_template.json") create_stack(context, full_name, body) elif desired_status == "CREATE_FAILED": body = read_template_file(context, "invalid_template.json") kwargs = {"OnFailure": "DO_NOTHING"} create_stack(context, full_name, body, **kwargs) elif desired_status == "UPDATE_COMPLETE": body = read_template_file(context, "valid_template.json") create_stack(context, full_name, body) body = read_template_file(context, "updated_template.json") update_stack(context, full_name, body) elif desired_status == "ROLLBACK_COMPLETE": body = read_template_file(context, "invalid_template.json") kwargs = {"OnFailure": "ROLLBACK"} create_stack(context, full_name, body, **kwargs) status = get_stack_status(context, full_name) assert (status == desired_status)
def step_impl(context, stack_name, desired_status): full_name = get_cloudformation_stack_name(context, stack_name) status = get_stack_status(context, full_name) if status != desired_status: delete_stack(context, full_name) if desired_status == "CREATE_COMPLETE": body = read_template_file(context, "valid_template.json") create_stack(context, full_name, body) elif desired_status == "CREATE_FAILED": body = read_template_file(context, "invalid_template.json") kwargs = {"OnFailure": "DO_NOTHING"} create_stack(context, full_name, body, **kwargs) elif desired_status == "UPDATE_COMPLETE": body = read_template_file(context, "valid_template.json") create_stack(context, full_name, body) body = read_template_file(context, "updated_template.json") update_stack(context, full_name, body) elif desired_status == "ROLLBACK_COMPLETE": body = read_template_file(context, "invalid_template.json") kwargs = {"OnFailure": "ROLLBACK"} create_stack(context, full_name, body, **kwargs) status = get_stack_status(context, full_name) assert (status == desired_status)
def step_impl(context, stack_name, change_set_name, filename): full_name = get_cloudformation_stack_name(context, stack_name) retry_boto_call(context.client.create_change_set, StackName=full_name, ChangeSetName=change_set_name, TemplateBody=read_template_file(context, filename)) wait_for_final_state(context, stack_name, change_set_name)
def step_impl(context, stack_name, template_name): full_name = get_cloudformation_stack_name(context, stack_name) status = get_stack_status(context, full_name) if status != "CREATE_COMPLETE": delete_stack(context, full_name) body = read_template_file(context, template_name) create_stack(context, full_name, body) status = get_stack_status(context, full_name) assert (status == "CREATE_COMPLETE")
def step_impl(context, stack_name, change_set_name, filename): full_name = get_cloudformation_stack_name(context, stack_name) retry_boto_call(context.client.create_change_set, StackName=full_name, Capabilities=[ 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM', 'CAPABILITY_AUTO_EXPAND' ], ChangeSetName=change_set_name, TemplateBody=read_template_file(context, filename)) wait_for_final_state(context, stack_name, change_set_name)
def step_impl(context, stack_name, template_name): full_name = get_cloudformation_stack_name(context, stack_name) status = get_stack_status(context, full_name) if status != "CREATE_COMPLETE": delete_stack(context, full_name) body = read_template_file(context, template_name) create_stack(context, full_name, body) status = get_stack_status(context, full_name) assert (status == "CREATE_COMPLETE")
def create_stacks(context, stack_names): body = read_template_file(context, "valid_template.json") for stack_name in stack_names: time.sleep(1) try: retry_boto_call(context.client.create_stack, StackName=stack_name, TemplateBody=body) except ClientError as e: if e.response['Error']['Code'] == 'AlreadyExistsException' \ and e.response['Error']['Message'].endswith("already exists"): pass else: raise e for stack_name in stack_names: wait_for_final_state(context, stack_name)
def create_stacks(context, stack_names): body = read_template_file(context, "valid_template.json") for stack_name in stack_names: time.sleep(1) try: retry_boto_call( context.client.create_stack, StackName=stack_name, TemplateBody=body ) except ClientError as e: if e.response['Error']['Code'] == 'AlreadyExistsException' \ and e.response['Error']['Message'].endswith("already exists"): pass else: raise e for stack_name in stack_names: wait_for_final_state(context, stack_name)