Skip to content

Commit

Permalink
Fix the destroy of 'aws_security_group' for mysql-primary/replica
Browse files Browse the repository at this point in the history
After #1530, we're hitting an error applying the plan:

```
Error: Error applying plan:

2 errors occurred:
	* aws_security_group.mysql-replica (destroy): 1 error occurred:
	* aws_security_group.mysql-replica: Error deleting security group: DependencyViolation: resource sg-26a3915d has a dependent object
	status code: 400, request id: 481cb159-77ee-46ef-813a-e82a9b91f754

	* aws_security_group.mysql-primary (destroy): 1 error occurred:
	* aws_security_group.mysql-primary: Error deleting security group: DependencyViolation: resource sg-d1bc8eaa has a dependent object
	status code: 400, request id: c9eee46f-f760-460f-929e-07e600d4c700
```

Trying a fix outlined in hashicorp/terraform-provider-aws#1671 (comment)
  • Loading branch information
ChrisBAshton committed Jan 28, 2022
1 parent 35c722d commit 7a100d2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions terraform/projects/infra-security-groups/mysql.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ resource "aws_security_group" "mysql-primary" {
description = "Access to mysql-primary from its clients"
count = 0

lifecycle {
create_before_destroy = true
}

tags {
Name = "${var.stackname}_mysql-primary_access"
}
Expand Down Expand Up @@ -81,6 +85,10 @@ resource "aws_security_group" "mysql-replica" {
description = "Access to mysql-replica from its clients"
count = 0

lifecycle {
create_before_destroy = true
}

tags {
Name = "${var.stackname}_mysql-replica_access"
}
Expand Down

0 comments on commit 7a100d2

Please sign in to comment.