title: Disassociate EIP before detaching IGW
body: <p>When I modify the subnet of my VPC, a whole new VPC is provisioned. The IGW is moved from the old VPC to the new one. Which would be fine if it wasn't prevented from moving because the Elastic IP is still attached to the instance.</p>
  
  <p>I tried many combinations with <code>depends_on</code>.</p>
  
  <p>If I manually disassociate the EIP, terraform IGW modification stops waiting for ever.</p>
  
  <pre><code>########################
  #      ELASTIC IP      #
  ########################
  resource "aws_eip" "ip" {}
  
  # EIP association isolated for testing "depends on"
  resource "aws_eip_association" "eip_assoc" {
    instance_id   = "${aws_instance.vpn_server.id}"
    allocation_id = "${aws_eip.ip.id}"
    depends_on = ["aws_internet_gateway.gw","aws_vpc.vpc"]
  }
  
  ########################
  #    VPC CREATION      #
  ########################
  resource "aws_vpc" "vpc" {
    cidr_block       = "${var.cidr}"
    enable_dns_support = true
    enable_dns_hostnames = true
    assign_generated_ipv6_cidr_block = "${var.ipv6}"
  }
  
  ########################
  #    IGW CREATION      #
  ########################
  resource "aws_internet_gateway" "gw" {
    vpc_id = "${aws_vpc.vpc.id}"
  }
  
  ########################
  #      Instance        #
  ########################
  resource "aws_instance" "vpn_server" {
    ami           = "${data.aws_ami.ami_amzn2.id}"
    instance_type = "t2.micro"
    key_name = "${aws_key_pair.key.key_name}"
    subnet_id = "${aws_subnet.a.id}"
    associate_public_ip_address = true
    ipv6_address_count = 1
    vpc_security_group_ids = ["${aws_default_security_group.sg.id}"]
    lifecycle { create_before_destroy = true }
    depends_on = ["aws_internet_gateway.gw"]
    user_data = "${data.template_file.user_data.rendered}"
  }
  
  ########################
  #   Subnets Creation   #
  ########################
  data "aws_availability_zones" "available" {}
  
  resource "aws_subnet" "a" {
      availability_zone = "${data.aws_availability_zones.available.names[0]}"
      vpc_id = "${aws_vpc.vpc.id}"
      cidr_block = "${cidrsubnet(aws_vpc.vpc.cidr_block, 2, 0)}"
      map_public_ip_on_launch = true
  
      # Bug Issue 688: https://github.com/terraform-providers/terraform-provider-aws/issues/688
      # Soon set even if no IPv6 for VPC
      # https://github.com/terraform-providers/terraform-provider-aws/pull/2103
      ipv6_cidr_block = "${var.ipv6 ? cidrsubnet(aws_vpc.vpc.ipv6_cidr_block, 8, 10) : ""}"
      assign_ipv6_address_on_creation = true
  }
  </code></pre>
  
  <p>Any idea what would be the correct way of disassociating the EIP before the IGW tries to move to the new VPC?</p>