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 no longer setting device_index=0 on network_interface #23766

Closed
fcheung opened this issue Mar 19, 2022 · 11 comments · Fixed by #23767
Closed

aws_launch_template no longer setting device_index=0 on network_interface #23766

fcheung opened this issue Mar 19, 2022 · 11 comments · Fixed by #23767
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@fcheung
Copy link
Contributor

fcheung commented Mar 19, 2022

As of 4.6.0 creating a launch template seems to result in a network interface with no device index

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.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/aws v4.6.0
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/template v2.2.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.

provider "aws" {}

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "4.6.0"
    }
  }
  required_version = "~> 1.1.7"
}


resource "aws_launch_template" "this" {
  name_prefix = "test"

  network_interfaces {
    security_groups             = []
    delete_on_termination       = true
  }
}

Debug Output

Panic Output

Expected Behavior

A launch template should be created with a network interface that has a device index of 0. This is the behaviour observed with version 4.5.0 of the provider.

Screenshot 2022-03-19 at 20 30 24

Actual Behavior

A launch template is created but the network interface has no device index. Trying to associate such a launch template with an autoscaling group ( : Incompatible launch template: Each network interface requires a unique device index. )

Screenshot 2022-03-19 at 20 33 54

Steps to Reproduce

  1. terraform apply

References

This seems like a regression of #4475 . It looks like commit a4cebe5 in #23365 reinstated a check that device index is not 0: https://github.com/hashicorp/terraform-provider-aws/blob/main/internal/service/ec2/launch_template.go#L1432

@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 19, 2022
@vara-bonthu
Copy link
Contributor

I have hit the same issue today with the latest provider version

@yanivomc
Copy link

same here and solved by going back to 4.5

@bschaatsbergen
Copy link
Member

bschaatsbergen commented Mar 20, 2022

This seems to be due to a condition that's added on device_index in 4.6.0 https://github.com/bschaatsbergen/terraform-provider-aws/blob/main/internal/service/ec2/launch_template.go#L1432

I see that @fcheung created a PR (#23767) to solve this 👍

@ewbankkit ewbankkit added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 21, 2022
@lystor
Copy link
Contributor

lystor commented Mar 21, 2022

It is impossible to use new resource aws_gamelift_game_server_group due to this bug.
Please revert to the previous behavior.
0 is a valid index in network interfaces.

@mperalta-1988
Copy link

I have the same issue from my side :/. I have issues creating autoscaling groups when the launch template doesn't have the device index assigned

@DmytroMorhulDevPro
Copy link

@mperalta-1988

terraform {
 required_providers {
   aws = {
     version = "4.5.0"
   }
 }
}

Going back to 4.5.0 wil fix the issue

@Whimby
Copy link

Whimby commented Mar 22, 2022

4.6 more like 4.miss

@smiller171
Copy link

If you generally don't like to pin specific versions, you can do this:

terraform {
 required_providers {
   aws = {
     version = "~> 4.5, != 4.6.0"
   }
 }
}

@github-actions
Copy link

This functionality has been released in v4.7.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@marek-obuchowicz
Copy link

marek-obuchowicz commented Mar 30, 2022

I see that 4.7.0 and 4.8.0 should have fix for this issue, however it seems that a launch template created by 4.6.0 affected by bug is still used. I've used 4.6.0 which created launch template v10, then failed to assign it to autoscaling group because of missing device index. Now version 4.8.0 fails with the same problem:

aws_autoscaling_group.nodes-k1-xxx-c-xxx-xxx: Modifying... [id=nodes.k1.xxx.c.xxx.xxx]
aws_launch_template.master-eu-central-1a-masters-k1-xxx-c-xxx-xxx: Modifying... [id=lt-03ed47bf77717844b]
aws_launch_template.master-eu-central-1c-masters-k1-xxx-c-xxx-xxx: Modifying... [id=lt-04eb5c11201cb2804]
aws_launch_template.master-eu-central-1b-masters-k1-xxx-c-xxx-xxx: Modifying... [id=lt-0d8787290a4572b22]
aws_launch_template.master-eu-central-1a-masters-k1-xxx-c-xxx-xxx: Modifications complete after 0s [id=lt-03ed47bf77717844b]
aws_launch_template.master-eu-central-1c-masters-k1-xxx-c-xxx-xxx: Modifications complete after 0s [id=lt-04eb5c11201cb2804]
aws_autoscaling_group.master-eu-central-1a-masters-k1-xxx-c-xxx-xxx: Modifying... [id=master-eu-central-1a.masters.k1.xxx.c.xxx.xxx]
aws_autoscaling_group.master-eu-central-1c-masters-k1-xxx-c-xxx-xxx: Modifying... [id=master-eu-central-1c.masters.k1.xxx.c.xxx.xxx]
aws_launch_template.master-eu-central-1b-masters-k1-xxx-c-xxx-xxx: Modifications complete after 0s [id=lt-0d8787290a4572b22]
aws_autoscaling_group.master-eu-central-1b-masters-k1-xxx-c-xxx-xxx: Modifying... [id=master-eu-central-1b.masters.k1.xxx.c.xxx.xxx]

Error: Error updating Auto Scaling Group: InvalidQueryParameter: Incompatible launch template: Each network interface requires a unique device index.
	status code: 400, request id: fa01aa64-1f4a-4df5-9fe6-dcd0bc8d9174

  on kubernetes.tf line 198, in resource "aws_autoscaling_group" "master-eu-central-1a-masters-k1-xxx-c-xxx-xxx":
 198: resource "aws_autoscaling_group" "master-eu-central-1a-masters-k1-xxx-c-xxx-xxx" {

and I see in AWS console, that for mentioned aws_autoscaling_group the last created version is on Mar 22 (when I was using 4.5.0). It seems that 4.8.0 for some reason didn't create new launch template versions and recognises those incorrect ones as latest.
To solve this issue, I had to use AWS GUI, find launch template versions with missing device index and delete them. After that, terraform plan / apply worked.

@github-actions
Copy link

github-actions bot commented May 5, 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 5, 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. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet