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

Unable to access private_ips list from aws_network_interface #3039

Closed
bryanstephens opened this issue Aug 20, 2015 · 6 comments
Closed

Unable to access private_ips list from aws_network_interface #3039

bryanstephens opened this issue Aug 20, 2015 · 6 comments

Comments

@bryanstephens
Copy link

I'm trying to create a collection of Elastic Network Interfaces using the following code:

resource "aws_network_interface" "zk_eni_pool" {
  count = 6
  subnet_id = "${element(split(",", module.coreos.private_subnets_string), count.index)}"
  security_groups = ["${module.coreos.asg_private_security_group_id}"]
  tags {
    IpPool = "${var.cluster_name}-zk"
  }
}

Those appear to get created just fine but then when I try to access the assigned private IPs on those interfaces from within a template_file I get the following error:

Error creating plan: 1 error(s) occurred:

* 1 error(s) occurred:

* Resource 'aws_network_interface.zk_eni_pool.0' does not have attribute 'private_ips' for variable 'aws_network_interface.zk_eni_pool.0.private_ips'

The template looks like following:

resource "template_file" "eni_coordinator_network_interface_policy" {
  filename = "${path.module}/files/eni-coordinator-network-interface-policy.json"
  vars {
    aws_region = "${var.aws_region}"
    zk_eni_1 = "${aws_network_interface.zk_eni_pool.0.private_ips}"
  }
}

If I inspect the tfstate file I see the following in the attributes of the aws_network_interface:

"aws_network_interface.zk_eni_pool.0": {
                    "type": "aws_network_interface",
                    "depends_on": [
                        "module.coreos",
                        "module.coreos"
                    ],
                    "primary": {
                        "id": "eni-77bc6f11",
                        "attributes": {
                            "attachment.#": "0",
                            "id": "eni-77bc6f11",
                            "private_ips.#": "1",
                            "private_ips.2885130951": "10.200.11.230",
                            "security_groups.#": "1",
                            "security_groups.4187308437": "sg-25812f41",
                            "source_dest_check": "true",
                            "subnet_id": "subnet-43733226",
                            "tags.#": "1",
                            "tags.IpPool": "bryan-stephens-zk"
                        }
                    }
                }

If I try to access the private ip using ${aws_network_interface.zk_eni_pool.0.private_ips.2885130951} then it will actually give me what I'm looking for, but I'm guessing that there is supposed to be a better way to handle this. I am running terraform 0.6.3 on OS X 10.10.4.

@catsby catsby added the bug label Aug 20, 2015
@josh-padnick
Copy link

I also experienced this issue. Here's a fully contained template that reproduces this issue:

provider "aws" {
    access_key = "${var.AWS_ACCESS_KEY_ID}"
    secret_key = "${var.AWS_SECRET_ACCESS_KEY}"
    region = "us-west-2"
}

resource "aws_security_group" "demo" {
  name = "demo-sg"
  description = "Demo Security Group"
}

resource "aws_instance" "demo" {
    ami = "ami-5189a661"
    instance_type = "t2.micro"
    key_name = "my_key_name"
    vpc_security_group_ids = [ "${aws_security_group.demo.id}" ]
    associate_public_ip_address = true
}

output "security_groups" {
  # Neither of these outputs a value...
  value = "${element(join(",", aws_instance.demo.vpc_security_group_ids),0)}"
  #value = "${aws_instance.demo.vpc_security_group_ids}"
}

@jszwedko
Copy link
Contributor

jszwedko commented Oct 5, 2015

#2157 appears to fix both of these issues

@phinze
Copy link
Contributor

phinze commented Oct 29, 2015

Hey folks, since #2157 is merged these should be all fixed up. Feel free to follow up if not. 👍

@phinze phinze closed this as completed Oct 29, 2015
@josh-padnick
Copy link

@phinze very good timing. I believe there may be a bug with #2157. See #3679.

@phinze
Copy link
Contributor

phinze commented Oct 29, 2015

@josh-padnick thanks for the ping - will go look

@ghost
Copy link

ghost commented Apr 30, 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 Apr 30, 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

6 participants