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

Error Destroying Aurora Global Cluster with Primary and Secondary Regional Clusters #13126

Closed
maryelizbeth opened this issue May 1, 2020 · 8 comments · Fixed by #14420
Closed
Assignees
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.
Milestone

Comments

@maryelizbeth
Copy link
Contributor

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 Version

Terraform v0.12.24

Affected Resource(s)

  • aws__rds_global_cluster

Terraform Configuration Files

resource "aws_rds_global_cluster" "global" {
  provider                  = aws.pri
  global_cluster_identifier = "test-cluster"

Expected Behavior

Actual Behavior

Aurora Global Clusters with one regional cluster work fine with changes from #12499. They can be created and destroyed, but a global cluster is created with primary and secondary regional clusters the error from #12499 persists:

* aws_rds_cluster.this: error deleting RDS Cluster (dbtfmodules-aurora-mysql-global-test-secondary): InvalidDBClusterStateFault: This cluster is a part of a global cluster, please remove it from globalcluster first
	status code: 400, request id: fc9e7a36-b486-4f0b-8418-3a81de125289

Steps to Reproduce

After trying and failing the first destroy, a seconddestroy works as expected.

Important Factoids

In the destroy debug.log, the secondary cluster was removed from the global cluster (RemoveFromGlobalCluster request) and then tried to DeleteDBCluster and resulted in error.

The time between this two requests is very short and maybe the unlink is not applied when it performs the DeleteDBCluster request.

Using either like waitForState function to detect the cluster is unlinked or something like thread.Sleep could potentially fix the issue.

References

@maryelizbeth maryelizbeth added bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service. needs-triage Waiting for first response or review from a maintainer. and removed needs-triage Waiting for first response or review from a maintainer. labels May 1, 2020
@maryelizbeth maryelizbeth self-assigned this May 1, 2020
@pandianp1971
Copy link

We have this issue with Terraform ENTP v0.12.24 / Provider 2.59. How soon we will get help on this?

@marinsalinas
Copy link

marinsalinas commented May 27, 2020

We have this issue with Terraform ENTP v0.12.24 / Provider 2.59. How soon we will get help on this?

@pandianp1971 I'm still having issues with as well cc @bflad since he is working on the latest rds changes.

@fphilippon
Copy link

Hello, we also have this issue.

@tinojam9
Copy link

tinojam9 commented Jun 9, 2020

We are also having this issue.

@marinsalinas
Copy link

marinsalinas commented Jun 18, 2020

@maryelizbeth

In order to give more context regarding this issue:

  1. We are using Terraform Enterprise
  2. We cannot provide the code since we have a lot of internal information but here is a very similar configuration we use.
provider "aws" {
 alias  = "sec"
region = "<secondary-region>"
}

resource "aws_rds_global_cluster" "global" {
  global_cluster_identifier = "test-cluster"
  engine                    = "aurora-mysql"
  engine_version            = "5.7.mysql_aurora.2.07.1"
  storage_encrypted         = false
}

resource "aws_rds_cluster" "primary_cluster" {
  availability_zones              = var.primary_availability_zones
  cluster_identifier              = var.cluster_name
  database_name                   = "test"
  engine                    = "aurora-mysql"
  engine_version            = "5.7.mysql_aurora.2.07.1"
  engine_mode	  = "provisioned"
  global_cluster_identifier       = aws_rds_global_cluster.global.id
  master_password                 = "test"
  master_username                 = "test"
  skip_final_snapshot             = true
  storage_encrypted               = false
  vpc_security_group_ids          = [var.primary_vpc]
}

resource "aws_rds_cluster_instance" "primary" {
  cluster_identifier           = aws_rds_cluster.primary_cluster.id
  engine                    = "aurora-mysql"
  engine_version            = "5.7.mysql_aurora.2.07.1"
  identifier                   = "${var.db_instance_name}"
  instance_class               = "db.r4.large"
}

resource "aws_rds_cluster" "secondary_cluster" {
  provider                        = aws.sec
  apply_immediately               = var.cluster_apply_change_immediately
  availability_zones              = var.sec_az
  cluster_identifier              = "${var.cluster_name}-sec"
  db_subnet_group_name            = "default-vpc-test"
  depends_on                      = [aws_rds_cluster_instance.primary]
  engine                    = "aurora-mysql"
  engine_mode	  = "provisioned"
  engine_version            = "5.7.mysql_aurora.2.07.1"
  global_cluster_identifier       = aws_rds_global_cluster.global.id
  skip_final_snapshot             = true
  storage_encrypted               = false
  vpc_security_group_ids          = [var.test_sec_groups]
}

resource "aws_rds_cluster_instance" "secondary" {
  provider                     = aws.sec
  cluster_identifier           = aws_rds_cluster.secondary_cluster.id
  db_subnet_group_name         = "default-vpc-test123"
  engine                    = "aurora-mysql"
  engine_version            = "5.7.mysql_aurora.2.07.1"
  identifier                   = "test_sec-sec"
  instance_class               = "db.r4.large"
  publicly_accessible          = false
}

Resources impacted:

  • aws_rds_global_cluster
  • aws_rds_cluster

More context:
The Aurora Global Cluster with one regional cluster works fine, we can create it and destroy it, but when we create the global cluster with primary and secondary regional clusters we got the same error:

 aws_rds_cluster.this: error deleting RDS Cluster (dbtfmodules-aurora-mysql-global-test-secondary): InvalidDBClusterStateFault: This cluster is a part of a global cluster, please remove it from globalcluster first status code: 400, request id: fc9e7a36-b486-4f0b-8418-3a81de125289

Then I run a subsequent destroy and works fine, so destroying two times is our workaround right now.

I’ve taken a look into the destroy destroy.log and saw that the secondary cluster was removed from the global cluster (RemoveFromGlobalCluster request) and then tried to DeleteDBCluster and got the error.

The time between these two requests is very short and maybe the unlink is not applied when it performs the DeleteDBCluster request. I’d recommend using either like waitForState function to detect the cluster is unlinked or something like thread.Sleep.

@anGie44
Copy link
Contributor

anGie44 commented Jul 31, 2020

A fix has been merged to address the error on delete and will release with v3.1.0 of the Terraform AWS Provider.

@ghost
Copy link

ghost commented Aug 7, 2020

This has been released in version 3.1.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 for triage. Thanks!

@ghost
Copy link

ghost commented Aug 31, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
7 participants