首页 > 解决方案 > 是否可以重用 cloudformation 模板中的现有路由表

问题描述

我正在编写一个 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。

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

解决方案


您的参数vpcId有效,因为它使用AWS::EC2::VPC::Id属于 CloudFormation 中支持的 AWS 特定参数类型的类型。

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


推荐阅读