amazon-web-services - 创建具有云形成的堆栈时出现问题 ("Property Type cannot be empty.")

标签 amazon-web-services cloud aws-cloudformation amazon-elb

所以,我目前遇到了这个问题,但没有多大意义,因为我已经在 LoadBalancerListener 上添加了类型... 我之前只测试了负载均衡器目标组,然后它们工作得很好,但是当我添加Listener,堆栈出现错误。这是代码:

AWSTemplateFormatVersion: 2010-09-09
Description: Template for load balancer

Resources: 
  DayOne:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Scheme: internet-facing
      SecurityGroups:
        - sg-055ea833725644075
      Subnets:
        - subnet-0d7b9bf57973e6b78
        - subnet-0186890795288d48a
  LoadBalancerListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      DefaultActions:
        - Type: forward
        - TargetGroupArn: !Ref TargetGroup
      LoadBalancerArn: !Ref DayOne
      Port: 80
      Protocol: "HTTP"
  TargetGroup:
    DependsOn: "DayOne"
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties: 
      TargetType: "instance"
      Name: "DayOneTarget"
      Port: 80
      Protocol: "HTTP"
      VpcId: "vpc-0f98d22c9291e3c0c"
      HealthyThresholdCount: 2
      HealthCheckTimeoutSeconds: 10
      HealthCheckIntervalSeconds: 30

问题是这样的:

enter image description here

最佳答案

正如我的评论,您的问题是您的 DefaultActions 列表配置错误。您需要删除第二个 -,以便您的操作被视为一个操作。当您添加第二个操作时,它会将 TargetGroupArnType 分开处理,并使其搜索第二个操作。

该错误消息可能看起来具有误导性,但它实际上告诉您缺少默认操作的 Type 字段。由于 Type 是必填字段,并且您有多个操作,因此每个操作都需要包含它。

它应该是什么样子:

  LoadBalancerListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties:
      DefaultActions:
        - Type: forward
          TargetGroupArn: !Ref TargetGroup
      LoadBalancerArn: !Ref DayOne
      Port: 80
      Protocol: "HTTP"

关于amazon-web-services - 创建具有云形成的堆栈时出现问题 ("Property Type cannot be empty."),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59664395/

相关文章:

Java,如何有效地对大型输入流进行分块?

amazon-web-services - 一个 Lambda 函数或多个 Lambda 函数

node.js - AWS同步lambda与nodejs的lambda调用

mysql - 如何将本地数据库的表数据上传到云服务?

amazon-web-services - Cloudformation 根堆栈引用

amazon-web-services - 无服务器:验证错误...成员必须满足正则表达式模式:表名

java - Redis (AWS Elasticache) 在一段时间后停止工作

带 EC2 的 Matlab/Octave

amazon-web-services - 在CloudFormation中使用Sub函数是否会妨碍bash脚本的使用?

amazon-ec2 - 声明式云形成/Terraform 中的动态 EC2 资源配置