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 ignores device_index=0 #4475

Closed
joernheissler opened this issue May 8, 2018 · 3 comments
Closed

aws_launch_template ignores device_index=0 #4475

joernheissler opened this issue May 8, 2018 · 3 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@joernheissler
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.11.6
+ provider.aws v1.17.0
+ provider.external v1.0.0
+ provider.local v1.1.0
+ provider.template v1.0.0

Affected Resource(s)

  • aws_launch_template

Terraform Configuration Files

resource "aws_launch_template" "loadtest" {
    name = "loadtest"
    description = "LoadTest"
    image_id = "${data.aws_ami.ubuntu_xenial.id}"
    instance_initiated_shutdown_behavior = "terminate"
    instance_type = "t2.small"
        
    placement {
        availability_zone = "eu-central-1a"
    }       
            
    network_interfaces {
        subnet_id = "${element(aws_subnet.stratus_private.*.id, 0)}"
# ----------------- Problem is here:
        device_index = 0
# -----------------
        delete_on_termination = true
        associate_public_ip_address = false
        security_groups = [
            "${aws_security_group.loadtest.id}",
        ]
    }
}

Expected Behavior

Terraform should submit the device index (0) to AWS.

Actual Behavior

Terraform ignores zero device index. AWS will then complain:
You must use a valid fully formed launch template. Each network interface requires a device index.

Steps to Reproduce

  1. Delete default VPC
  2. Create new (non-default) VPC, subnets, etc. etc. etc.
  3. Use above resource and an autoscale group which uses the launch template.

Important Factoids

By deleting the default VPC, AWS will complain No default VPC for this user. So I specified network_interfaces like above and got the problem described above.

I quick fixed the issue in aws/resource_aws_launch_template.go:

    if v, ok := ni["device_index"].(int); ok && v != 0 {
        networkInterface.DeviceIndex = aws.Int64(int64(v))
    }

I removed && v != 0 and when I first destroyed the resource, it got created correctly on next apply. But updates don't work, probably another comparison that needs fixing.

@bflad bflad added bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. labels May 8, 2018
@bflad
Copy link
Contributor

bflad commented May 8, 2018

FYI there's already a PR associated with this: #4367

@bflad bflad added this to the v1.19.0 milestone May 10, 2018
@bflad
Copy link
Contributor

bflad commented May 11, 2018

The simple fix of removing the v != 0 check has been merged into master via #4367 and will release with v1.19.0 of the AWS provider, likely middle of next week. If there are other continuing issues after that, please open a new issue. Thanks!

@bflad bflad closed this as completed May 11, 2018
@ghost
Copy link

ghost commented Apr 6, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
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