-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
changing identifier in RDS (aws_db_instance) will destroy/create the db #507
Comments
This would be great if Terraform didn't try to destroy my DB instances when doing a "DB instance identifier change". Something you can do easily in the AWS console. So my current workaround is to change the db instance id via AWS console, manually change my tfstate json, and then run |
It looks like this is supported via |
Hi, has any progress been made here? Thanks! |
Hi, Thanks! |
Hi, Thanks! |
AWS does support an unique identifier:
|
I ran into this one today as we wanted to change naming convention. If anyone else hits this you can work around with some state tinkering: change instance identifier in the AWS console (fair warning, will cause instance to be unavailable while RDS endpoint will changes, for about 10 mins). This is very convoluted so keen for a fix 🙏 |
We wait for this fix with impatience. Our restore from the backup process involves creating a duplicate DB instance, moving the data there, removing/renaming the old instance and finally renaming the new instance to match the old one, so the endpoint remains unchanged. Without this feature we're forced to use the console and direct state modification, which requires the operator to have the access AWS account through the UI and access keys. It is not desirable from security perspective, as we want Terraform Cloud to be the only way to access AWS. |
I think I figured out how to make it work - but it will be backward incompatible change ( |
Alright I think I finished with tests and docs... that's crazy how long tests runs since pretty much any action agains RDS takes literally forever :( |
Also looking into the code I realized that |
What should happen if the |
I think the rule of thumb is - as long as the resource address in the state file stays the same, providers should put in their best effort to avoid resource re-creation. Not sure if I covered this in my PR, probably not - it's been over a year now. |
Hi all 👋 Just letting you know that this is issue is featured on this quarters roadmap. If a PR exists to close the issue a maintainer will review and either make changes directly, or work with the original author to get the contribution merged. If you have written a PR to resolve the issue please ensure the "Allow edits from maintainers" box is checked. Thanks for your patience and we are looking forward to getting this merged soon! |
As this would change the resource ID it is considered a breaking change and should be implemented in a major version. |
We just ran into this issue ourself. An innocent naming change that would allow us to monitor the DB better just deleted all of our data, including backups. Luckily we double checked the deployment before rolling it out on Prod, but it is unacceptable that this issue has been open for more than 5 years and there is still no fix. I've been defending Terraform against my colleagues for its ease of use and cross-provider features, but this issue doesn't help with that. |
I just ran into this problem. |
Workaround that worked for me:
*sidenote for 2nd point, you will need to adjust any other part of your code it if uses outputs from RDS resource/module. |
We can use the parameter identifier to change RDS identifier during RDS creation. |
This functionality has been released in v5.0.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
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. |
This issue was originally opened by @adrianlop as hashicorp/terraform#11636. It was migrated here as part of the provider split. The original body of the issue is below.
Terraform Version
0.8.5
Affected Resource(s)
Expected Behavior
Using AWS RDS UI you can change the identifier and it won't recreate the database, it will only apply it on the preferred maintenance window/apply immediately if you select it.
This change also changes the endpoint, so AWS will give you a warn as expected:
Warning! Endpoint will also change
.Actual Behavior
Terraform will destroy + recreate the instance. It should only apply the change in the maintenance window or immediately if you selected
apply_immediately=true
, not destroy the DB.Thanks.
The text was updated successfully, but these errors were encountered: