AWS Cloudformation + Beanstalk错误无效的YAML模板

时间:2016-11-21 17:41:33

标签: amazon-web-services amazon-ec2 elastic-beanstalk amazon-cloudformation boto3

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

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

  

错误无效的Yaml :“”中不允许使用映射值   CacheSecurityGroupName:Ref:“CacheSecurityGroup”   ^,JSON异常:无效的JSON:位置0处的意外字符(R)。更新配置文件。   错误:无法部署应用程序。

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

寻找解决问题的指示

1 个答案:

答案 0 :(得分:3)

您应该在新行中使用完整的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"