【问题标题】:associate more than one subnets in route table subnet association using cloudformation yaml使用 cloudformation yaml 在路由表子网关联中关联多个子网
【发布时间】:2020-03-04 17:43:19
【问题描述】:

我在 yaml 中使用 amazon cloudformation 创建了堆栈。

• 具有 4 个子网(2 个公共和 2 个私有)的 VPC。

• 每个公有和私有子网都放置在 AZ ap-south-1a (1 公共、1 个私有和 ap-south-1b(1 个公共和 1 个私有)。

• 为公共子网和私有子网创建路由表。

• 尝试将 1a 和 1b 的公共子网关联到公共 RT 但它不起作用。但是如果我将 1 个子网关联到这个公共 rt 它确实有效。

如何使用 cloudformation (yaml) 将多个子网关联到一个路由表?

提前致谢。

CFPublicRT:
    Type: AWS::EC2::RouteTable
    Properties:
      Tags:
        - Key: Name
          Value: Public RT
      VpcId: !Ref CFVPC
  CFPrivateRT:
    Type: AWS::EC2::RouteTable
    Properties:
      Tags:
        - Key: Name
          Value: Private RT
      VpcId: !Ref CFVPC
  routetablepublicsubnetassociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref CFPublicRT
        SubnetId: !Ref CFPublicSubnet1a
  routetableprivatesubnetassociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId: !Ref CFPrivateRT
      SubnetId: !Ref CFPrivateSubnet1a

【问题讨论】:

    标签: amazon-web-services yaml amazon-cloudformation


    【解决方案1】:

    你可以这样使用:

    SubnetARouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTablePublic
        SubnetId: !Ref PublicSubnetA
    SubnetBRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTablePublic
        SubnetId: !Ref PublicSubnetB
    SubnetCRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTablePrivate
        SubnetId: !Ref PrivateSubnetC
    SubnetDRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTablePrivate
        SubnetId: !Ref PrivateSubnetD
    

    【讨论】:

      猜你喜欢
      • 2021-02-25
      • 2017-07-15
      • 2019-01-15
      • 1970-01-01
      • 1970-01-01
      • 2020-04-04
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多