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

Could not get all ipv6 information(ipv6_addresses) from terraform.tfstate file #8408

Closed
SerenaLi279 opened this issue Apr 23, 2019 · 5 comments · Fixed by #12281
Closed

Could not get all ipv6 information(ipv6_addresses) from terraform.tfstate file #8408

SerenaLi279 opened this issue Apr 23, 2019 · 5 comments · Fixed by #12281
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@SerenaLi279
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.11

  • provider.aws v2.7.0

Affected Resource(s)

*aws_network_interface
*aws_instance

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
variable "net-01_ids" {}
resource "aws_network_interface" "net-01" {
  subnet_id = "${element(split(",", var.net-01_ids), var.zone_index)}"
  security_groups = [ "${split(",", var.security_group_ids)}"]
  source_dest_check = false
  tags {
    Name = "${var.tag_name}"
  }
}
variable "net-02_ids" {}
resource "aws_network_interface" "net-02" {
  subnet_id = "${element(split(",", var.net-02_ids), var.zone_index)}"
  security_groups = [ "${split(",", var.security_group_ids)}"]
  source_dest_check = false
  tags {
    Name = "${var.tag_name}"
  }
}

resource "aws_instance" "instance" {
    ami = "${var.source_ami}"
    instance_type = "${var.instance_type}"
    key_name = "${var.ssh_key_pair}" 

    network_interface {
    network_interface_id = "${aws_network_interface.net-01.id}"
    device_index = 0
   } 

    network_interface {
    network_interface_id = "${aws_network_interface.net-02.id}"
    device_index = 1
   } 

    user_data = "${file("${var.user_data_file}")}" 

    root_block_device {
        delete_on_termination = true
        volume_size = "200"
        volume_type = "gp2"
    }

    tags {
        Name = "${var.tag_name}"
        Alias = "${var.tag_name}"
        sshUser = "${var.ssh_username}"
        role = "${var.role}"
        KubernetesCluster = "${var.short_name}"
        "kubernetes.io/cluster/serena" = "${var.short_name}"
    }
}

Debug Output

Expected Behavior

I enabled Auto-assign IPv6 address, and when instance launched there are 2 ipv6 address configured in the instance:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 02:c1:87:29:a3:cc brd ff:ff:ff:ff:ff:ff
    inet 192.16.1.53/24 brd 192.16.1.255 scope global dynamic eth0
       valid_lft 2486sec preferred_lft 2486sec
    inet6 2600:1f16:89a:9e01:4688:1a59:e66:10b4/64 scope global dynamic 
       valid_lft 442sec preferred_lft 142sec
    inet6 fe80::c1:87ff:fe29:a3cc/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 02:ff:a1:d0:44:1c brd ff:ff:ff:ff:ff:ff
    inet 192.16.1.92/24 brd 192.16.1.255 scope global dynamic eth1
       valid_lft 2491sec preferred_lft 2491sec
    inet6 2600:1f16:89a:9e01:589:29e0:8517:84ec/64 scope global dynamic 
       valid_lft 381sec preferred_lft 81sec
    inet6 fe80::ff:a1ff:fed0:441c/64 scope link 

Expected: Could get ipv6 information like ipv6 address form 'aws_network_interface' of terraform.tfstate file.

Actual Behavior

There are no ipv6 information in 'aws_network_interface' of terraform.tfstate file.

                "aws_network_interface.net-01": {
                    "type": "aws_network_interface",
                    "depends_on": [],
                    "primary": {
                        "id": "eni-0ac6ec627d24b1f6b",
                        "attributes": {
                            "attachment.#": "0",
                            "description": "",
                            "id": "eni-0ac6ec627d24b1f6b",
                            "private_dns_name": "",
                            "private_ip": "192.16.1.53",
                            "private_ips.#": "1",
                            "private_ips.1071487055": "192.16.1.53",
                            "security_groups.#": "1",
                            "security_groups.791620435": "sg-befcc7d4",
                            "source_dest_check": "false",
                            "subnet_id": "subnet-17b6e97f",
                            "tags.%": "1",
                            "tags.Name": "serena-01"
                        },
                        "meta": {},
                        "tainted": false
                    },
                    "deposed": [],
                    "provider": "provider.aws"
                }

Could only get one ipv6 address of eth0 in 'aws_instance.instance' from terraform.tfstate file.

               "aws_instance.instance": {
                    "type": "aws_instance",
                    "depends_on": [
                        "aws_network_interface.net-01",
                        "aws_network_interface.net-02"
                    ],
                    "primary": {
                        "id": "i-0688d68e26e8b427f",
                        "attributes": {
...
                            "instance_type": "c4.xlarge",
                            "ipv6_address_count": "1",
                            "ipv6_addresses.#": "1",
                            "ipv6_addresses.0": "2600:1f16:89a:9e01:4688:1a59:e66:10b4",

Steps to Reproduce

Right click the subnet with you want to use ipv6, and then click Modify auto-assign IP settings
Select the check box Auto-assign IPv6 and Save.
Then use this subnet as I decribed in Terraform Configuration Files

  1. terraform apply
@aeschright aeschright added the needs-triage Waiting for first response or review from a maintainer. label Jun 19, 2019
@aeschright aeschright added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jul 3, 2019
@SerenaLi279
Copy link
Author

Hi @aeschright,
any update for this?

@SerenaLi279
Copy link
Author

The data "aws_network_interface" supports IPv6, the a resource "aws_network_interface" does not.
WA:
Set the AssignIpv6AddressOnCreation attribute to true in the subnet, then use both resource "aws_network_interface" and data "aws_network_interface", could get ipv6 address from data "aws_network_interface" in terraform.tfstate file.

resource "aws_network_interface" "net-01" {
  subnet_id = element(split(",", var.net-01_ids), var.zone_index)
  security_groups = split(",", var.security_group_ids)
  source_dest_check = false
  tags = {
    Name = var.tag_name
  }
}
data "aws_network_interface" "data-net-01" {
  id = aws_network_interface.net-01.id
}

result:

      "module": "module.serena-c-01",
      "mode": "data",
      "type": "aws_network_interface",
      "name": "data-net-02",
      "provider": "provider.aws",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "association": null,
            "attachment": null,
            "availability_zone": "us-east-2a",
            "description": "",
            "filter": null,
            "id": "eni-0230d495xxx",
            "interface_type": "interface",
            "ipv6_addresses": [
              "2xxx:1f16:5e4:bxxx:af87:27d:xxx:xxx"
            ],

@ewbankkit ewbankkit added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 26, 2020
@bflad bflad added this to the v3.12.0 milestone Oct 16, 2020
@bflad
Copy link
Member

bflad commented Oct 16, 2020

Support for new ipv6_addresses and ipv6_address_count arguments in the aws_network_interface resource has been merged and will release with version 3.12.0 of the Terraform AWS Provider, next week. Thanks to @DrFaust92 for the implementation. 👍

@ghost
Copy link

ghost commented Oct 22, 2020

This has been released in version 3.12.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 for triage. Thanks!

@ghost
Copy link

ghost commented Nov 16, 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 as resolved and limited conversation to collaborators Nov 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants