-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/aws: DB Instance skip_final_snapshot #3853
provider/aws: DB Instance skip_final_snapshot #3853
Conversation
} else { | ||
skipFinalSnapshot := d.Get("skip_final_snapshot").(bool) | ||
opts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot) | ||
if !skipFinalSnapshot && d.Get("final_snapshot_identifier").(string) != "" { |
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.
Unverified but I think you might be able to use GetOk
here instead of Get
and avoid the check.
@stack72 I think this is the correct approach versus special casing the final snapshot name, but I'll leave it up to @catsby or @phinze to have a final say on this as they're more likely to know of precedent that may have been set elsewhere in Terraform. I've made a few comments inline with respect to the code if this is the correct approach. |
e99e438
to
174fb20
Compare
opts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot) | ||
|
||
if name, present := d.GetOk("final_snapshot_identifier"); present && !skipFinalSnapshot { | ||
opts.FinalDBSnapshotIdentifier = aws.String(name.(string)) | ||
} |
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.
If the user has skip_final_snapshot = false
in their config, but omits final_snapshot_identifier
(valid config as we have things now), then no final snapshot will be taken. We should error in this case.
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.
I think that makes sense :) Adding it now
Thanks for the PR @stack72! I have some questions though. As it stands I don't think this is a good move, but I'm open for discussing it. Currently, if the user wants a final snapshot before deleting, the must specify the identifier in their config, or no snapshot will be taken. The proposed change is an optional parameter with default of Specifying I pointed out above in a code comment that as it stands, specifying What are your thoughts on these? |
@catsby I am just trying to solve the problem from the original issue - I haven't personally come up against the issue as we always take a snapshot. I think if you have a think about the original issue (linked) then I am happy to go whatever way you think is necessary |
Reading up on #3848 and re-thinking, perhaps this is a thing we do need. I think If we default to Does that sound reasonable? I think that would address #3848 by allowing that user to leave their |
@catsby agree with this approach - this would mean no backwards functionality changes which rocks :) |
👍 for preserving current behaviour here. This looks good to me. One thing - is it worth an acceptance test here to prevent regression since there is some (albeit simple) logic and the worst case is a snapshot not being made where one is expected? |
Agree an acceptance test would be best here... I'm not sure how to do it though, thoughts? Create two instances, one without |
That description sounds right, @catsby. It's a bit of a dance, but it would be nice to cover the snapshot behavior since it's really important to get that right for prod databases. 😀 |
I'll get this test added over the weekend :) |
… to specify whether a snapshot is needed directly rather than checking for an empty string
…uired but yet no identified is given
cc5d21f
to
2b0c7aa
Compare
@jen20 / @catsby / @phinze finally got around to writing some tests for this. The Snapshot test cleans up after itself and deletes the snapshot in the CheckDestroy func Creating a final Snapshot
Skipping a final snapshot
Build is currently running :) |
LGTM. Thanks @stack72! |
provider/aws: add DB Instance skip_final_snapshot
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Fixes #3848
Adding skip_final_snapshop bool to th db_instance. This will allow us to specify whether a snapshot is
needed directly rather than checking for an empty string
Added as per the docs rather than checking for an empty string on final_snapshot_identifier