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

Replacing an aws_key_pair does not update related aws_instance(s) #10497

Open
thrixton opened this issue Oct 13, 2019 · 4 comments
Open

Replacing an aws_key_pair does not update related aws_instance(s) #10497

thrixton opened this issue Oct 13, 2019 · 4 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@thrixton
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 "me too" comments, 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.10
provider.aws v2.30.0

Affected Resource(s)

aws_key_pair
aws_instance

Terraform Configuration Files

Key

resource "aws_key_pair" "ec2_key_pair" {
  key_name   = "${var.project}-${var.environment}-ec2-key"
  public_key = "${var.ec2_key_public_data}"
}

Instance

resource "aws_instance" "ec2_test" {
  ami                         = "${var.test_ec2_ami}"
  instance_type               = "t2.micro"
  vpc_security_group_ids      = ["${var.security_group_id}"]
  subnet_id                   = "${var.subnet_id}"
  associate_public_ip_address = false
  key_name                    = "${aws_key_pair.ec2_key_pair.key_name}"

  tags        = merge(local.project_tags, local.test_resource_tags, { Name = "${upper(var.project)}-${upper(var.environment)} Test", type = "ec2-instance" })
  volume_tags = merge(local.project_tags, local.test_resource_tags, { type = "storage-ec2" })
}

Expected Behavior

When a key is replaced (such as when imported per #1092), the associated instances are not also updated.
This is due to Terraform's diffing behaviour, as per Update/replace resource when a dependency is changed, #8099.
This issue is just as an example for the issue above.

Actual Behavior

Terraform does not recreate the instance(s).

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

Where the linked issue #8099 is about wanting an update to trigger depends_on, this appears to be about a resource cycle that destroys a resource, and that destroy does not cause depends_on to resource cycle the dependent resource. Since depends_on is supposed to trigger these ordering operations, this one seems more like a bug.

@justinretzolk
Copy link
Member

Hey @thrixton 👋 Thank you for taking the time to file this issue! Given that there's been a number of AWS provider releases since you initially filed it, can you confirm whether you're still experiencing this behavior?

@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 Dec 9, 2021
@oxcug
Copy link

oxcug commented Jan 20, 2022

@justinretzolk can confirm. I just ran into this (found the ticket via search).

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Jan 20, 2022
@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Jan 21, 2022
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 Dec 15, 2024
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/ec2 Issues and PRs that pertain to the ec2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
Development

No branches or pull requests

4 participants