AWS CDK (.NET) 无法创建临时网关附件

AWS CDK (.NET) Unable to create Transient Gateway Attachment

我有一个带有 private/public 个子网(使用 CDK 创建)的现有 VPC 和一个未处于挂起状态的现有临时网关(手动创建)。我现在正在尝试修改我的堆栈以创建 VPC Transit Gateway 附件,但我的代码没有找到 Transit Gateway。这是代码:

// create a VPC attachment to the transit gateway
var transitGatewayAttachment = new CfnTransitGatewayAttachment(this, "TransitGatewayAttachment", new CfnTransitGatewayAttachmentProps 
{ 
   VpcId = Vpc.VpcId,
   TransitGatewayId = "tgw-xxxxxx",     
   SubnetIds = Vpc.PrivateSubnets.Select(s => s.SubnetId).ToArray()
});

CDK returns Transit Gateway 不存在的错误。 CloudFormation 也是如此。我对 tgw id 进行了两次和三次检查,所以我对问题可能是什么感到困惑。

实际上,问题是在创建附件和通过我的路线 table 修改可供使用之间存在延迟。所以我能够创建附件 OK(上面的代码很好)但是无法使用以下代码从私有子网路由到它。显示的是使之成为可能的变化。

var index = 0;    
Vpc.PrivateSubnets.ToList().ForEach(s =>
{
    var route = new CfnRoute(this, $"TgwRoute{index}", new CfnRouteProps
    {
        DestinationCidrBlock = "xxx.xxx.xxx.xxx/xx", 
        RouteTableId = s.RouteTable.RouteTableId,
        TransitGatewayId = "tgw-xxxxxx"  
    });
    route.AddDependsOn(transitGatewayAttachment); // *** <--- *** This adds a dependency on TGW
    index++;
});