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

aws_launch_template device_index 0 is not set to eth0 for some reason #23807

Closed
daftkid opened this issue Mar 22, 2022 · 2 comments
Closed

aws_launch_template device_index 0 is not set to eth0 for some reason #23807

daftkid opened this issue Mar 22, 2022 · 2 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@daftkid
Copy link
Contributor

daftkid commented Mar 22, 2022

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 v1.1.4
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.6.0

Affected Resource(s)

  • aws_launch_template

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_launch_template" "tpl-1" {
  name_prefix   = "${local.name_prefix}-1-lt-"
  image_id      = var.asg_instance_ami
  instance_type = var.asg_instance_type
  key_name      = aws_key_pair.key.key_name
  user_data     = base64encode(data.template_file.userdata.rendered)

  iam_instance_profile {
    name = aws_iam_instance_profile.instance_profile.name
  }

  block_device_mappings {
    device_name = "/dev/xvda"

    ebs {
      delete_on_termination = true
      volume_size           = var.asg_instance_root_volume_size
      volume_type           = var.asg_instance_root_volume_type
      encrypted             = var.asg_instance_root_volume_encrypted
      kms_key_id            = aws_kms_key.kms_key.arn
    }
  }

  network_interfaces {
    device_index         = 0
    network_interface_id = aws_network_interface.if-1-private.id
  }

  network_interfaces {
    device_index         = 1
    network_interface_id = aws_network_interface.if-1-mng.id
  }

  network_interfaces {
    device_index         = 2
    network_interface_id = aws_network_interface.if-1-public.id
  }

  lifecycle {
    create_before_destroy = true
  }

  tag_specifications {
    resource_type = "volume"
    tags          = { "Name" = "${local.name_prefix}-volume" }

  }
}

Debug Output

Panic Output

Expected Behavior

I want Terraform to create Launch template with Network interfaces mapping to device indices where device_index: 0 should be mapped to eth0, device_index: 1 to eth1 and so on.

Actual Behavior

I'm deploying this code in AWS China (Beijing) region and faced the issue: network interface with device_index = 0 is not mapped to eth0 in Launch template for some reason. Network interfaces with device index > 0 just are mapped correctly, I can see that launch template has mappings for eth1 and eth2. I can also see that interface with device_index = 0 is also present however it does not have mapping to eth0 and thus further ASG creation from this LT is failed with an error: Error creating Auto Scaling Group: InvalidQueryParameter: Incompatible launch template: Each network interface requires a unique device index.

Statefile has information that device_index for this "problematic" interface is 0.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service. labels Mar 22, 2022
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 22, 2022
@ewbankkit
Copy link
Contributor

@daftkid Thanks for raising this issue.
It has already been noticed in #23766. I'm going to close this one as a duplicate so that we can concentrate discussion in the linked issue.
Please add any additional comments there.

@github-actions
Copy link

github-actions bot commented May 7, 2022

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 May 7, 2022
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/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

2 participants