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

Terraform Instance creation for ENI with Secondary private private IPs greater than 1 Fails #15886

Closed
pranshuverma opened this issue Aug 23, 2017 · 3 comments

Comments

@pranshuverma
Copy link

Terraform Version

Terraform v0.10.0

Your version of Terraform is out of date! The latest version
is 0.10.2. You can update by downloading from www.terraform.io

Terraform Configuration Files

resource "aws_network_interface" "nic" {
  count = ..
  subnet_id = ..
  # private_ips = ..
  private_ips_count = ..
  security_groups = ..
  source_dest_check = ..
  tags = ..
}

resource "aws_instance" "vm" {
  ami                         = ..
  instance_type               = ..
  # vpc_security_group_ids      = ..
  key_name                    = ..
  # subnet_id                   = .. 
  # associate_public_ip_address = ..
  count                       = ..
  # source_dest_check           = false

  lifecycle {
    prevent_destroy = false
  }

  root_block_device {
    volume_size = ..
    delete_on_termination = ..
  }

  volume_tags = ..

  depends_on = ["aws_network_interface.nic"]
  network_interface {
    network_interface_id = "${aws_network_interface.nic.*.id[count.index]}"
    device_index = 0
  }

  tags = ..
}

Debug Output

module.vm.aws_instance.vm: Still creating... (10s elapsed)
2017/08/23 03:31:55 [ERROR] root.vm: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* aws_instance.vm: Error waiting for instance (i-xxx) to become ready: Failed to reach target state. Reason: Server.InternalError: Internal error on launch
2017/08/23 03:31:55 [ERROR] root.vm: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* aws_instance.vm: Error waiting for instance (i-xxx) to become ready: Failed to reach target state. Reason: Server.InternalError: Internal error on launch
2017/08/23 03:31:55 [TRACE] [walkApply] Exiting eval tree: module.vm.aws_instance.vm
2017/08/23 03:31:55 [DEBUG] dag/walk: upstream errored, not walking "provider.aws (close)"
Error applying plan:

1 error(s) occurred:

* module.vm.aws_instance.vm: 1 error(s) occurred:

* aws_instance.vm: Error waiting for instance (i-xxx) to become ready: Failed to reach target state. Reason: Server.InternalError: Internal error on launch

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Expected Behavior

The Instance should be created

Actual Behavior

The instance creation with primary nic with multiple ips works for private ip count as 1 but if i enter say 2 or 3 private ip count it fails.

Error: Reason: Server.InternalError: Internal error on launch (in terminal and in aws instance section also.)

Steps to Reproduce

I referred to https://www.terraform.io/docs/providers/aws/r/instance.html the Network Interfaces section.

@pranshuverma pranshuverma changed the title Terraform Instance creation for ENI with private IPs greater than 1 fails Terraform Instance creation for ENI with Secondary private private IPs greater than 1 Fails Aug 23, 2017
@hashibot
Copy link
Contributor

This issue has been automatically migrated to hashicorp/terraform-provider-aws#1490 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to this issue and let us know.

@alencar
Copy link

alencar commented Mar 9, 2019

This is a bit old, but I just went through the same problem and I want to share how I managed to fix it.

aws_network_interface resource documentation is a bit unhelpful here, as it does not clear states that private_ips_count means secondary private ips, instead of the total count.

Since instances have different limits of IP's per interface, people will encounter this errors with different number of IPs and instance types.

The following code will result in an ENI with 3 private IP address instead of two. This is because there will be always one primary IP. The parameter private_ips_count should be better documented to inform about the default primary IP or better yet, match AWS API name secondary_private_ip_address_count or secondary_private_ips_count.

resource "aws_network_interface" "three-private-ips" {
...
private_ips_count = 2
...
}

If you want to define using pre-existing allocations, you can use private_ips, the first address will be the primary one. The code below will produce an ENI with 3 private IPs, where 1.1.1.100 is the primary one.

resource "aws_network_interface" "three-private-ips" {
...
private_ips = ["1.1.1.100", "1.1.1.2", "1.1.1.3"]
...
}

@ghost
Copy link

ghost commented Mar 29, 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 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.

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants