云形成:从路由引用NAT网关会产生无效ID:“nat-0ad5d1c106dd74175”

时间:2017-06-22 19:39:51

标签: networking amazon-cloudformation nat

我有以下Cloud Formation配置,包括子网,路由表/路由,nat网关和弹性IP:

  lambdaPointToIgwStaging:
    Type: 'AWS::EC2::Subnet'
    Properties:
      VpcId: !Ref mainVpc
      CidrBlock: '210.12.172.0/20'
      AvailabilityZone: eu-west-1b
  lambdaEipStaging:
    Type: 'AWS::EC2::EIP'
    Properties:
    Domain: 'vpc'
  lambdaNatGatewayStaging:
    Type: 'AWS::EC2::NatGateway'
    Properties:
      AllocationId: !GetAtt lambdaEipStaging.AllocationId
      SubnetId: !Ref lambdaPointToIgwStaging
  lambdaNatRoute:
    Type: 'AWS::EC2::Route'
    Properties:
      DestinationCidrBlock: '0.0.0.0/0'
      InstanceId: !Ref lambdaNatGatewayStaging
      RouteTableId: !Ref lambdaToNatStaging
    DependsOn: lambdaNatGatewayStaging
  lambdaToNatStaging:
    Type: 'AWS::EC2::RouteTable'
    Properties:
      VpcId: !Ref mainVpc

在创建lambdaNatRoute时失败,错误Invalid id: "nat-0ad5d1c106dd74175"错误完全无用。我尝试了各种dependsOn配置但似乎没有任何帮助。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

最后通过AWS支持,答案是在我的路线定义中使用NatGatewayId而不是InstanceId

  lambdaNatRoute:
   Type: 'AWS::EC2::Route'
   Properties:
     DestinationCidrBlock: '0.0.0.0/0'
     NatGatewayId: !Ref lambdaNatGatewayStaging
     RouteTableId: !Ref lambdaToNatStaging