Skip to content

RouteTable creation fails when using transitGatewayID RAM #2692

@asaldalop

Description

@asaldalop

Describe the bug
When I try to create a new RouteTable object using the spec routes.transitGatewayID, the EC2 controller version 1.6.2 fails to create a single route and instead repeatedly creates multiple route tables during each reconciliation loop but incorrectly. It's important to mention that the transitGatewayID already exists in the AWS account it's shared by another AWS account (Transit Gateway with AWS RAM)

Steps to reproduce
Create a route table with the following specifications (the Transit Gateway already exists and was shared by another AWS account).

apiVersion: ec2.services.k8s.aws/v1alpha1
kind: RouteTable
metadata:
  name: my-route-table
spec:
  vpcRef:
    from:
      name: my-test-vpc
  routes:
    - destinationCIDRBlock: 10.0.0.0/8
      transitGatewayID: "tgw-0a1b2c3d4e5f6789a"
    - destinationCIDRBlock: 192.168.0.0/16
      transitGatewayID: "tgw-0a1b2c3d4e5f6789a"

Expected outcome
Single RouteTable created with the defined route, but I got the following error instead:

{"level":"error","ts":"2025-11-11T14:19:57.265Z","msg":"Reconciler error","controller":"routetable","controllerGroup":"ec2.services.k8s.aws","controllerKind":"RouteTable","RouteTable":{"name":"my-route-table","namespace":"my-namespace"},"namespace":"my-namespace","name":"my-route-table","reconcileID":"db2068fe-8e68-45fe-b1f7-8a17041d222d","error":"operation error EC2: CreateRoute, https response error StatusCode: 400, RequestID: b8067c4a-ecc4-4f14-8330-be0149b5ab74, api error InvalidTransitGatewayID.NotFound: The transitGateway ID 'tgw-0a1b2c3d4e5f6789a' does not exist.","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:347\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:294\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:255"}

Environment

  • Kubernetes version: 1.32.6
  • Using EKS (yes/no), if so version? yes
  • AWS service targeted (S3, RDS, etc.): EC2 Controller v.1.6.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.service/ec2Indicates issues or PRs that are related to ec2-controller.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions