Skip to content
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 the cluster identifier in an aws_rds_cluster resource should not destroy/recreate the cluster #20363

Closed
gblues opened this issue Jul 29, 2021 · 5 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service.

Comments

@gblues
Copy link

gblues commented Jul 29, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform version: 1.0.3
AWS provider version: 3.42.0

Affected Resource(s)

  • aws_rds_cluster
  • aws_rds_cluster_instance

Terraform Configuration Files

NOTE: Creating the networking infrastructure (VPC, subnets, and db subnet group) are left as an exercise to the reader since they are not relevant to the issue.

locals {
  instance_identifier = "my-name"
  cluster_identifier = local.instance_identifier
  engine_version = "5.7.mysql_aurora.2.04.5"
}

resource "aws_rds_cluster" "aurora" {
  cluster_identifier = local.cluster_identifier
  engine             = "aurora-mysql"
  engine_version     = local.engine_version
  port               = 3306
  database_name      = "te"
  master_username    = "master"
  apply_immediately  = true
  storage_encrypted  = false

  master_password      = "choose_your_own_password"
  db_subnet_group_name = "your-db-subnet-group-name"


  deletion_protection       = false
  skip_final_snapshot       = true

  vpc_security_group_ids          = []
  backup_retention_period         = 1

  enabled_cloudwatch_logs_exports = []
}

resource "aws_rds_cluster_instance" "aurora" {
  cluster_identifier              = local.cluster_identifier
  identifier                      = local.instance_identifier
  instance_class                  = "db.t3.medium"
  engine                          = "aurora-mysql"
  engine_version                  = local.engine_version
  ca_cert_identifier              = "rds-ca-2019"
  depends_on                      = [aws_rds_cluster.aurora]
  apply_immediately               = true
  auto_minor_version_upgrade      = false
  performance_insights_enabled    = false
}

Debug Output

https://gist.github.com/gblues/082f3fac11b5a6bc72c717f25493a94b

Expected Behavior

The cluster should be renamed.

Actual Behavior

The cluster is destroyed and re-created, meaning any data stored in the cluster is lost.

Steps to Reproduce

  1. Apply the above code
  2. Change the cluster identifier to "${local.instance_identifier}-cluster"
  3. run terraform plan

Important Factoids

By contrast, the AWS console allows one to modify the cluster and change the cluster ID with no data loss.

References

I found an issue opened years ago on this issue on the main terraform repo, but it was never interacted with:

hashicorp/terraform#11636

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/rds Issues and PRs that pertain to the rds service. labels Jul 29, 2021
@anGie44
Copy link
Contributor

anGie44 commented Jul 29, 2021

Referenced in #507

@anGie44 anGie44 added bug Addresses a defect in current functionality. enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. bug Addresses a defect in current functionality. labels Jul 29, 2021
@github-actions
Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Jul 20, 2023
@gblues
Copy link
Author

gblues commented Jul 21, 2023

Appears to be resolved in the 5.0.0 release of the AWS provider. Thank you!

#507 (comment)

@gblues gblues closed this as completed Jul 21, 2023
@github-actions github-actions bot removed the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Jul 21, 2023
@enchorb
Copy link

enchorb commented Jul 27, 2023

still not solved for aws_rds_cluster_instance

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

No branches or pull requests

3 participants