-
Notifications
You must be signed in to change notification settings - Fork 0
Add revert_previous_change_set method to the Stack class #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,6 +168,8 @@ def create_change_set(options) | |
| def apply_change_set(params: {}, wait: false) | ||
| logger.info("**** DRY RUN ****") if dry_run | ||
|
|
||
| @previous_parameters = deployed_parameters | ||
|
|
||
| logger.info("Updating #{name} stack...") | ||
|
|
||
| params = parameters_for_update(overrides: params) | ||
|
|
@@ -220,6 +222,18 @@ def apply_change_set(params: {}, wait: false) | |
| change_set | ||
| end | ||
|
|
||
| def revert_to_previous_change_set(wait: false) | ||
| logger.info("**** DRY RUN ****") if dry_run | ||
|
|
||
| if @previous_parameters | ||
| logger.info("Reverting to previous change set...") | ||
| apply_change_set(params: @previous_parameters, wait: wait) | ||
| @previous_parameters = nil | ||
| else | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous change set could also have had a different stack template. So we'd need to use that too? (the change set we are trying to revert could be using both new parameter values and a new template). Code like https://github.com/openstax/aws-ruby/blob/master/lib/openstax/aws/stack.rb#L59-L60 is maybe helpful.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this something which may happen only when we code this directly, like in the test: In this case, it seems like it would be not possible to retrieve the first template data using cached It seems like this case for creating a new stack class and calling I was thinking about passing What do you think would be the best option to allow reverting templates?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about this? #69
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good, I've added some fixes and updated cassettes: #71 |
||
| logger.info("There are no saved previous parameters for #{name} stack.") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be an error?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not call an |
||
| end | ||
| end | ||
|
|
||
| def delete(wait: false) | ||
| logger.info("**** DRY RUN ****") if dry_run | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to persist the previous parameters or template somewhere? If the process dies, these instance variables will be lost and we will no longer be able to revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's a good question. I'm not sure if this should be done in this or a in a separate issue. I also don't know what would be the best way to achive this - some temp file?
cc @TomWoodward