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

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

Closed
peteromoon opened this issue Apr 11, 2017 · 3 comments

Comments

@peteromoon
Copy link

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

@UnclaimedPants
Copy link

@peteromoon I've run into this same issue too.

@aschepp
Copy link

aschepp commented May 11, 2017

We also run into this issue.

@ghost
Copy link

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

5 participants