【问题标题】:is it possible to reuse existing route table in cloudformation template是否可以在 cloudformation 模板中重用现有路由表
【发布时间】:2026-01-17 01:25:01
【问题描述】:

我正在编写一个 cft 来连接 dynamodb uisng vpcEndpoint。

      DynamoDBEndpoint:
        Type: "AWS::EC2::VPCEndpoint"
        Properties:
          RouteTableIds:
            - !Ref PublicRouteTable
            - !Ref Private0RouteTable
            - !Ref Private1RouteTable
            - !Ref Private2RouteTable
          ServiceName:
            !Sub "com.amazonaws.${AWS::Region}.dynamodb"
          VpcId: !Ref VPC

Parameters:
  vpcId:
    Description: Choose the existing one
    Type: AWS::EC2::VPC::Id

我通过使用参数获取现有的 vpcId,有什么办法可以利用我现有的路由表,请建议我如何定义这个 ref PublicRouteTable 和 ref PrivateRouteTable。

【问题讨论】:

  • 您到底遇到了什么错误?此外,您提供的模板无效。
  • 嗨,我只想知道我应该如何获得这个 routetableId ?
  • 您将它们作为输入参数传递给您的模板。
  • 我将如何通过?你能提一下吗,因为我没有像 vpc 这样的 Id。
  • 你必须事先知道ID。从您的问题中不清楚您真正要实现什么。如果您没有路由 ID,您希望如何在模板中使用它们?

标签: amazon-cloudformation aws-cloudformation-custom-resource


【解决方案1】:

您的参数 vpcId 有效,因为它使用 CloudFormation 中属于 Supported AWS-specific parameter typesAWS::EC2::VPC::Id 类型。

遗憾的是,CloudFormation does not support 路由表的类似类型。指定参数时,必须在控制台中手动输入路由表 ID。

【讨论】:

    最近更新 更多