【问题标题】:Cloudformation Route Erroring OutCloudformation 路由出错
【发布时间】:2022-01-20 23:53:06
【问题描述】:

我正在创建一条到我的互联网网关的公共路由。当我通过 GUI 进行配置时,完全没有问题。当我尝试通过我的 Cloudformation 模板执行此操作时,每次都失败。这是网关的构造,没有任何问题:

GatewayToInternet:
  Type: AWS::EC2::InternetGateway
  DependsOn: VPC
  Properties:
    Tags:
    - Key: Name
      Value: !Sub ${AWS::StackName}-IGW
  AttachGateway:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref VPC
      InternetGatewayId: !Ref GatewayToInternet

这是我附加的导致问题的路线:

PublicDefaultRoute1
  Type: AWS::EC2::Route
  DependsOn: GatewayToInternet
  Properties:
    RouteTableId: !Ref PublicRouteTable
    GatewayId: !Ref GatewayToInternet
    DestinationCidrBlock: 0.0.0.0/0

我从 CLI 得到的错误是:调用 CreateStack 操作时发生错误 (ValidationError):模板格式错误:YAML 格式不正确。 (第 261 行,第 5 列)

如果我删除路线,一切都会完美运行。我没有任何其他路由附加到该路由表,如果这很重要的话。

【问题讨论】:

  • 您能否使用 YAML 验证器确认您的模板没有无效的 YAML 语法?编辑:没关系,我发现了问题
  • 我不敢相信我错过了。谢谢!

标签: amazon-cloudformation


【解决方案1】:
PublicDefaultRoute1
  Type: AWS::EC2::Route
  DependsOn: GatewayToInternet
  Properties:
    RouteTableId: !Ref PublicRouteTable
    GatewayId: !Ref GatewayToInternet
    DestinationCidrBlock: 0.0.0.0/0

应该是

PublicDefaultRoute1:
  Type: AWS::EC2::Route
  DependsOn: GatewayToInternet
  Properties:
    RouteTableId: !Ref PublicRouteTable
    GatewayId: !Ref GatewayToInternet
    DestinationCidrBlock: 0.0.0.0/0

注意 PublicDefaultRoute1 中的冒号 (:)

【讨论】:

    猜你喜欢
    • 2020-04-04
    • 2019-04-06
    • 2020-05-07
    • 2020-07-01
    • 1970-01-01
    • 2017-07-15
    • 2020-08-28
    • 1970-01-01
    • 2022-01-11
    相关资源
    最近更新 更多