AWS Cloudformation+Beanstalk 错误 Invalid YAML template

AWS Cloudformation+Beanstalk error Invalid YAML template

我在 ubuntu 上使用 aws eb deploy 命令来部署如下所示的 cloudformation 脚本。我收到如下所示的错误。

注意:我的其他 cloudformation 脚本运行没有任何问题。

Error Invalid Yaml: mapping values are not allowed here in "" CacheSecurityGroupName: Ref: "CacheSecurityGroup" ^, JSON exception: Invalid JSON: Unexpected character (R) at position 0.. Update the configuration file. ERROR: Failed to deploy application.

Resources:
  CacheSecurityGroupIngress:
    Type: "AWS::ElastiCache::SecurityGroupIngress"
    Properties:
      CacheSecurityGroupName: Ref: "CacheSecurityGroup"
      EC2SecurityGroupName: Ref: "AWSEBSecurityGroup"

寻找解决问题的指点

您应该在新行中使用完整的 Ref 函数形式,如下所示:

Resources:
  CacheSecurityGroupIngress:
    Type: "AWS::ElastiCache::SecurityGroupIngress"
    Properties:
      CacheSecurityGroupName:
        Ref: "CacheSecurityGroup"
      EC2SecurityGroupName:
        Ref: "AWSEBSecurityGroup"

...或者像这样的缩写形式:

Resources:
  CacheSecurityGroupIngress:
    Type: "AWS::ElastiCache::SecurityGroupIngress"
    Properties:
      CacheSecurityGroupName: !Ref "CacheSecurityGroup"
      EC2SecurityGroupName: !Ref "AWSEBSecurityGroup"