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

Destroying a Target Group fails due to dependency issue #13294

Open
random930 opened this issue May 13, 2020 · 8 comments
Open

Destroying a Target Group fails due to dependency issue #13294

random930 opened this issue May 13, 2020 · 8 comments
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.

Comments

@random930
Copy link

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

Affected Resource(s)

  • aws_lb_target_group

Terraform Configuration Files

resource "aws_lb_target_group" "main" {
	name = "streamdelayer-lb-tg"
	port = 80
	protocol = "TCP"
	vpc_id = aws_vpc.external.id

	target_type = "ip"

	depends_on = [aws_lb.main]

	health_check {
		interval = 10
		port = 8000
		protocol = "tcp"
	}
}

resource "aws_lb_listener" "main" {
	load_balancer_arn = aws_lb.main.arn
	port = "80"
	protocol = "TCP"

	default_action {
		type = "forward"
		target_group_arn = aws_lb_target_group.main.arn
	}

	depends_on = [aws_lb_target_group.main]
}

Expected Behavior

If I make a change to the target_group in the TF file and run a normal "terraform apply", it should have destroyed the listener before the target_group, then rebuilt both, to avoid the error I experirenced.

Actual Behavior

I made a change to a target_group and ran "terraform apply". I got this in return:

aws_lb_target_group.main: Destroying... [id=arn:aws:elasticloadbalancing:us-east-2:473085186055:targetgroup/streamdelayer-lb-tg/7c9ead1bdaea9467]

Error: Error deleting Target Group: ResourceInUse: Target group 'arn:aws:elasticloadbalancing:us-east-2:473085186055:targetgroup/streamdelayer-lb-tg/7c9ead1bdaea9467' is currently in use by a listener or a rule
	status code: 400, request id: 5e7362db-f60c-426f-820c-dbe9c861c8a5

(It didn't try to destroy the listener for some reason, even when I added depends-on, which I didn't have originally)

Then, I tried destroying the same resource specifically: "terraform destroy -target=aws_lb_target_group.main"

And that worked:

aws_lb_listener.main: Destroying... [id=arn:aws:elasticloadbalancing:us-east-2:473085186055:listener/net/streamdelayer-lb/baf23672a324cb16/938699982d1aae65]
aws_lb_listener.main: Destruction complete after 1s
aws_lb_target_group.main: Destroying... [id=arn:aws:elasticloadbalancing:us-east-2:473085186055:targetgroup/streamdelayer-lb-tg/7c9ead1bdaea9467]
aws_lb_target_group.main: Destruction complete after 0s

Steps to Reproduce

See above

@ghost ghost added the service/elbv2 Issues and PRs that pertain to the elbv2 service. label May 13, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label May 13, 2020
@sworisbreathing
Copy link
Contributor

@random930 this looks to be the same issue as #5699

@random930
Copy link
Author

random930 commented May 26, 2020 via email

@acdha
Copy link
Contributor

acdha commented Sep 15, 2020

I hit this recently with 0.13 and it's a little worse than it was in #5699, #636, etc. There's no way to solve this using name because the listener update will be blocked waiting for the previous target group to delete, and that will also fail to trigger updates to any target group attachments you have. Using name_prefix works but then you're stuck with the inability to have a name longer than 6 characters.

@justinretzolk
Copy link
Member

Hey @random930 👋 Thank you for taking the time to submit this issue. Given that there's been a few Terraform and AWS Provider releases since you initially filed it, can you confirm whether you're still running into this?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 27, 2021
@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 27, 2021
@MAXxATTAXx
Copy link

I can confirm this is happening on terraform v1.0.5 and v1.07

@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Sep 30, 2021
@jobwat
Copy link

jobwat commented Jan 23, 2022

Still an issue

I can't get terraform to destroy the aws_lb_listener_rule which is blocking the destroy of aws_lb_target_group

Error: error deleting Target Group: ResourceInUse: Target group 'xx' is currently in use by a listener or a rule
Terraform v1.1.4
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.72.0

@matmalone
Copy link

In my situation the least bad work-around I could figure out is tainting the associated aws_lb_listener before running apply.

@a0s
Copy link

a0s commented Nov 10, 2023

Any news on that?
I had to move to name_prefix and now it looks disgusting, like a old_na485638753658376438.
It also takes downtime to make such a transition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

No branches or pull requests

8 participants