Skip to content

aws_route Error: more than 1 targe specified if you change the destination type #684

@hashibot

Description

@hashibot

This issue was originally opened by @peteromoon as hashicorp/terraform#13530. It was migrated here as part of the provider split. The original body of the issue is below.


If you change the destination type of an aws_route, for example from a network interface (network_interface_id) to an internet gateway (gateway_id), when you run terraform apply it fails with:

* aws_route.test: 1 error(s) occurred:

* aws_route.test: Error: more than 1 target specified. Only 1 of gateway_id, egress_only_gateway_id, nat_gateway_id, instance_id, network_interface_id, route_table_id or vpc_peering_connection_id is allowed.

This type of change could occur if you change a subnet from being "private" to "public" or change from using an instance as a NAT gateway to using an AWS NAT gateway.

Terraform Version

$ terraform -v
Terraform v0.9.2

Affected Resource(s)

Please list the resources as a list, for example:

  • aws_route

Terraform Configuration Files

Step 1, Terraform config

{
  "provider" : {
    "aws" : {
      "region" : "eu-west-1"
    },
  },
  "resource" : {
    "aws_route_table" : {
      "test" : {
        "vpc_id" : "${aws_vpc.test.id}",
        "propagating_vgws" : [ ],
      }
    },
    "aws_route" : {
      "test" : {
        "destination_cidr_block" : "0.0.0.0/0",
        "network_interface_id" : "${aws_network_interface.test.id}",
        "route_table_id" : "${aws_route_table.test.id}"
      }
    },
    "aws_route_table_association" : {
      "test" : {
        "subnet_id" : "${aws_subnet.test.id}",
        "route_table_id" : "${aws_route_table.test.id}"
      }
    },
    "aws_internet_gateway" : {
      "test" : {
        "vpc_id" : "${aws_vpc.test.id}",
      }
    },
    "aws_vpc" : {
      "test" : {
        "cidr_block" : "10.247.0.0/17",
        "instance_tenancy" : "default",
        "enable_dns_support" : true,
        "enable_dns_hostnames" : true,
      }
    },
    "aws_subnet" : {
      "test" : {
        "vpc_id" : "${aws_vpc.test.id}",
        "availability_zone" : "eu-west-1a",
        "cidr_block" : "10.247.0.0/23",
      }
    },
    "aws_network_interface" : {
      "test" : {
        "source_dest_check" : false,
        "subnet_id": "${aws_subnet.test.id}"
      }
    }
  }
}

Step 2, Terraform config

{
  "provider" : {
    "aws" : {
      "region" : "eu-west-1"
    },
  },
  "resource" : {
    "aws_route_table" : {
      "test" : {
        "vpc_id" : "${aws_vpc.test.id}",
        "propagating_vgws" : [ ],
      }
    },
    "aws_route" : {
      "test" : {
        "destination_cidr_block" : "0.0.0.0/0",
        "gateway_id" : "${aws_internet_gateway.test.id}",
        "route_table_id" : "${aws_route_table.test.id}"
      }
    },
    "aws_route_table_association" : {
      "test" : {
        "subnet_id" : "${aws_subnet.test.id}",
        "route_table_id" : "${aws_route_table.test.id}"
      }
    },
    "aws_internet_gateway" : {
      "test" : {
        "vpc_id" : "${aws_vpc.test.id}",
      }
    },
    "aws_vpc" : {
      "test" : {
        "cidr_block" : "10.247.0.0/17",
        "instance_tenancy" : "default",
        "enable_dns_support" : true,
        "enable_dns_hostnames" : true,
      }
    },
    "aws_subnet" : {
      "test" : {
        "vpc_id" : "${aws_vpc.test.id}",
        "availability_zone" : "eu-west-1a",
        "cidr_block" : "10.247.0.0/23",
      }
    },
    "aws_network_interface" : {
      "test" : {
        "source_dest_check" : false,
        "subnet_id": "${aws_subnet.test.id}"
      }
    }
  }
}

Expected Behavior

The route to destination 0.0.0.0/0 is changed from a network interface to the internet gateway when the terraform config is changed and terraform apply is run.

Actual Behavior

terraform apply failed with an error when route is changed in terraform config from a network interface destination to an internet gateway destination.

Steps to Reproduce

To reproduce:

  1. Using Step 1 terraform config (see above) run: terraform apply
  2. Change route destination from network interface to internet gateway to produce Step 2 terraform config (see above)
  3. Run terraform apply
  4. Fails with error above.

References

I found this issue that is similar

Metadata

Metadata

Assignees

Labels

bugAddresses a defect in current functionality.service/ec2Issues and PRs that pertain to the ec2 service.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions