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

Duplicated aws_volume_attachment configurations cause incorrect behavior #19479

Closed
unixtastic opened this issue May 22, 2021 · 2 comments
Closed
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@unixtastic
Copy link

unixtastic commented May 22, 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 v0.15.1
provider: hashicorp/aws v3.42.0

Affected Resource(s)

  • aws_volume_attachment

Terraform Configuration Files

resource "aws_instance" "test1" {
  ami                     = "ami-08eae9b2b97caf274"
  availability_zone       = "eu-west-1a"
  disable_api_termination = false
  instance_type           = "t4g.nano"
  key_name                = "max-new-2015-10-15"
  vpc_security_group_ids = ["sg-0d9e0d8a3549cc53d"]
  subnet_id =  "subnet-04ca42d27fecd1c5e"
  tags = {
    Name      = "test1"
  }
}
resource "aws_ebs_volume" "test1-extravol" {
  availability_zone = "eu-west-1a"
  type              = "gp3"
  encrypted         = true
  size              = 1
  tags = {
    Name = "test1-extravol"
  }
}
resource "aws_volume_attachment" "test1-extravol" { 
  device_name = "/dev/sdf" 
  volume_id   = aws_ebs_volume.test1-extravol.id 
  instance_id = aws_instance.test1.id 
} 
#resource "aws_volume_attachment" "another" {
#  device_name = "/dev/sdf"
#  volume_id   = aws_ebs_volume.test1-extravol.id
#  instance_id = aws_instance.test1.id
#}

Debug Output

None

Panic Output

None

Expected Behavior

Creating duplicate aws_volume_attachment objects should not be allowed.

Actual Behavior

Two aws_volume_attachment objects are added to the state when the steps below are followed. These two objects have different names, but the exact same configuration.

Steps to Reproduce

  1. Define one instance, volume, and aws_volume_attachment to connect the two.
  2. Apply the config - no error
  3. Define a duplicate aws_volume_attachment with the same volume_id and instance_id, use a different name.
  4. Apply the config - no error but there are now two aws_volume_attachment objects in the state. These have the same id, instance_id, and volume_id.
  5. Run terraform again - nothing to change.
  6. Remove either aws_volume_attachment object from the config.
  7. Apply the config - the attachment is removed, the disk is split off from the server.
  8. Run terraform again - the attachment is added again.

Important Factoids

I'm using a VPC and existing subnet groups and SSH keys. I'm running in eu-west-1 and using t4g.nano instances. This doesn't seem relevant but I mention this for completeness.

References

I did not find any open bugs that seem related.

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

@unixtastic Thanks for raising this issue 👏.
This behavior is a current limitation of the Terraform Plugin SDK and Terraform Core.
There is a tracking issue for this: hashicorp/terraform-plugin-sdk#224.
Please add any information you think may be useful to the linked issue.

@ewbankkit ewbankkit added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels May 24, 2021
@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 Jun 24, 2021
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/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

2 participants