hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.83k stars 9.17k forks source link

aws_route_table and aws_default_route_table don't work / crash #21039

Closed DagrutCr closed 11 months ago

DagrutCr commented 3 years ago

Terraform Version

Terraform v0.12.31

Your version of Terraform is out of date! The latest version
is 1.0.7. You can update by downloading from https://www.terraform.io/downloads.html

Terraform Configuration Files

variable "AWS_ACCESS_KEY" {
}
variable "AWS_SECRET_KEY" {
}
variable "AWS_REGION" {
}

provider "aws" {
  access_key = var.AWS_ACCESS_KEY
  secret_key = var.AWS_SECRET_KEY
  region     = var.AWS_REGION
}

resource "aws_vpc" "vpc" {
  cidr_block       = "192.168.0.0/16"
  instance_tenancy = "default"

  tags = {
    Name = "Test VPC"
  }
}

resource "aws_subnet" "subnet" {
  vpc_id            = aws_vpc.vpc.id
  cidr_block        = "192.168.0.0/16"
  availability_zone = "${var.AWS_REGION}a"

  tags = {
    Name = "Test Subnet"
  }
}

resource "aws_internet_gateway" "gw" {
  vpc_id = aws_vpc.vpc.id

  tags = {
    Name = "Test GW"
  }
}

resource "aws_default_route_table" "route_table" {
  default_route_table_id = aws_vpc.vpc.default_route_table_id

  route = [
    {
      cidr_block = "0.0.0.0/0"
      gateway_id = aws_internet_gateway.gw.id

      # Somehow these are required...
      ipv6_cidr_block            = null
      destination_prefix_list_id = null
      egress_only_gateway_id     = null
      gateway_id                 = null
      instance_id                = null
      nat_gateway_id             = null
      network_interface_id       = null
      transit_gateway_id         = null
      vpc_endpoint_id            = null
      vpc_peering_connection_id  = null
    }
  ]
}

Debug Output & Crash Output

See : https://gist.github.com/DagrutCr/8f4f654104e64fb5c3a97d9c8ae6500f

Expected Behavior

Create or update route tables properly...

Actual Behavior

Crash when attempting to create or edit a route table, default or not

Steps to Reproduce

  1. terraform init
  2. terraform apply -var AWS_REGION=eu-west-3 -var "AWS_ACCESS_KEY=$key" -var "AWS_SECRET_KEY=$secret" -auto-approve

Additional Context

I did not include an example for normal route tables because that is the exact same issue (requiring all variables to be set for each route, and then crashing because nothing is set, even if it is).

References

Issue initially posted here : https://github.com/hashicorp/terraform/issues/29643

GPKyte commented 3 years ago

I notice that gateway_id is set twice in this example.

DagrutCr commented 3 years ago

Indeed, I added these lines from a previous error message but anyway, with or without the second gateway_id line the issue is the same.

In my case I had to use the AWS API to configure it :-/ .

justinretzolk commented 2 years ago

Hey @DagrutCr 👋 I recently reverted a change to the documentation that I think might be applying to you here. You can see details about the pull request here: https://github.com/hashicorp/terraform-provider-aws/pull/21740. Can you update your configuration with that change in mind and see if that resolves your issue?

github-actions[bot] commented 1 year ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 10 months ago

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.