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

intermittent route table creation that has no ID #7644

Closed
staebler opened this issue Feb 21, 2019 · 2 comments · Fixed by #17319
Closed

intermittent route table creation that has no ID #7644

staebler opened this issue Feb 21, 2019 · 2 comments · Fixed by #17319
Assignees
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@staebler
Copy link
Contributor

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.10
terraform-provider-aws: v1.29.0

Affected Resource(s)

  • aws_route_table

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
}

data "aws_availability_zones" "azs" {}

locals {
  new_subnet_azs = "${data.aws_availability_zones.azs.names}"
  new_az_count = "${length(local.new_subnet_azs)}"
  new_private_cidr_range = "${cidrsubnet(data.aws_vpc.cluster_vpc.cidr_block,1,1)}"
  vpc_id = "${aws_vpc.new_vpc.id}"
}

data "aws_vpc" "cluster_vpc" {
  id = "${local.vpc_id}"
}

resource "aws_vpc" "new_vpc" {
  cidr_block           = "10.0.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support   = true
}

resource "aws_route_table" "private_routes" {
  count  = "${local.new_az_count}"
  vpc_id = "${data.aws_vpc.cluster_vpc.id}"
}

resource "aws_subnet" "private_subnet" {
  count = "${local.new_az_count}"
  vpc_id = "${data.aws_vpc.cluster_vpc.id}"
  cidr_block = "${cidrsubnet(local.new_private_cidr_range, 3, count.index)}"
  availability_zone = "${local.new_subnet_azs[count.index]}"
}

resource "aws_route_table_association" "private_routing" {
  count          = "${local.new_az_count}"
  route_table_id = "${aws_route_table.private_routes.*.id[count.index]}"
  subnet_id      = "${aws_subnet.private_subnet.*.id[count.index]}"
}

Debug Output

https://gist.github.com/staebler/612476a267f426aa89bdc86c525db614

Panic Output

Expected Behavior

Either the creation of the route table is successful and the route table has an ID. Or the creation of the route table is unsuccessful.

Actual Behavior

The creation of the route table is successful but the route table has no ID. This causes subsequent resources that depend upon the route table to fail.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

@bflad bflad added the service/ec2 Issues and PRs that pertain to the ec2 service. label Feb 22, 2019
staebler added a commit to staebler/terraform-provider-aws that referenced this issue Mar 1, 2019
The typical route table creation steps involve making an ec2/CreateRouteTable
request, an ec2/DescribeRouteTables request, some other requests to update
the route table, followed by a final ec2.DescribeRouteTables request. If
the response to the final ec2/DescribeRouteTables request is
InvalidRouteTableID.NotFound, then the ID of the route table resource is
cleared so that the route table resource is not retained. However, the
creation is still considered a success. This results in either (1) failures
from other resources that depend upon the route table resource or (2) a report
of a successful apply even though one of the resources needed does not
actually exist.

These changes adjust the result of the creation in the case where the route
table cannot be found on the final ec2/DescribeRouteTables request. Instead
of reporting success for the creation, report failure.

Fixes hashicorp#7644
@aeschright aeschright added the needs-triage Waiting for first response or review from a maintainer. label Jun 24, 2019
@aeschright aeschright added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 22, 2019
YakDriver pushed a commit to ewbankkit/terraform-provider-aws that referenced this issue Mar 29, 2021
The typical route table creation steps involve making an ec2/CreateRouteTable
request, an ec2/DescribeRouteTables request, some other requests to update
the route table, followed by a final ec2.DescribeRouteTables request. If
the response to the final ec2/DescribeRouteTables request is
InvalidRouteTableID.NotFound, then the ID of the route table resource is
cleared so that the route table resource is not retained. However, the
creation is still considered a success. This results in either (1) failures
from other resources that depend upon the route table resource or (2) a report
of a successful apply even though one of the resources needed does not
actually exist.

These changes adjust the result of the creation in the case where the route
table cannot be found on the final ec2/DescribeRouteTables request. Instead
of reporting success for the creation, report failure.

Fixes hashicorp#7644
@github-actions github-actions bot added this to the v3.35.0 milestone Mar 29, 2021
@YakDriver YakDriver self-assigned this Mar 29, 2021
@ghost
Copy link

ghost commented Apr 1, 2021

This has been released in version 3.35.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 Apr 29, 2021

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 Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
4 participants