【问题标题】:Invalid template property or properties [ElasticacheCluster]无效的模板属性或属性 [ElasticacheCluster]
【发布时间】:2021-05-19 22:46:05
【问题描述】:

我收到了标题中提到的错误,我不知道如何解决它。 错误在 ElasticacheCluster 部分。 我尝试以多种方式对其进行修改,这就是为什么有一些注释的代码行但我没有删除它们可能有助于故障排除。 这是我下面的代码:

    #### Creating Elasticache ####

  ElasticacheSecurityGroup:
    Type: 'AWS::EC2::SecurityGroup'
    Properties:
      GroupDescription: Elasticache Security Group
      VpcId: !Ref PubPrivateVPC
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: '11211'
          ToPort: '11211'
          CidrIp: 0.0.0.0/0
      Tags:
        -
          Key: "Name"
          Value: !Join [_, [!Ref 'AWS::StackName',ElasiCache-SG]]
#          SourceSecurityGroupName: !Ref InstanceSecurityGroup

  CacheSubnetGroup:
    Type: 'AWS::ElastiCache::SubnetGroup'
    Properties:
      Description: cache
      SubnetIds:
        - !Ref PrivateSubnet1
        - !Ref PrivateSubnet2
        - !Ref PrivateSubnet3

ElasticacheCluster:
  Type: AWS::ElastiCache::CacheCluster
  Properties:    
    Engine: memcached
    EngineVersion: 1.6.6
    CacheNodeType: cache.t2.micro
    CacheSubnetGroupName: !Ref CacheSubnetGroup
    NumCacheNodes: '1'
#    VpcId: !Ref PubPrivateVPC
    VpcSecurityGroupIds: !Ref ElasticacheSecurityGroup
#      - !GetAtt 
#        - ElasticacheSecurityGroup
#        - GroupId

【问题讨论】:

    标签: amazon-web-services yaml amazon-cloudformation memcached aws-elasticache


    【解决方案1】:

    您的集群资源没有缩进。

    这应该可以工作:

      ElasticacheSecurityGroup:
        Type: 'AWS::EC2::SecurityGroup'
        Properties:
          GroupDescription: Elasticache Security Group
          VpcId: !Ref PubPrivateVPC
          SecurityGroupIngress:
            - IpProtocol: tcp
              FromPort: '11211'
              ToPort: '11211'
              CidrIp: 0.0.0.0/0
          Tags:
            -
              Key: "Name"
              Value: !Join [_, [!Ref 'AWS::StackName',ElasiCache-SG]]
    #          SourceSecurityGroupName: !Ref InstanceSecurityGroup
    
      CacheSubnetGroup:
        Type: 'AWS::ElastiCache::SubnetGroup'
        Properties:
          Description: cache
          SubnetIds:
            - !Ref PrivateSubnet1
            - !Ref PrivateSubnet2
            - !Ref PrivateSubnet3
    
      ElasticacheCluster:
        Type: AWS::ElastiCache::CacheCluster
        Properties:    
          Engine: memcached
          EngineVersion: 1.6.6
          CacheNodeType: cache.t2.micro
          CacheSubnetGroupName: !Ref CacheSubnetGroup
          NumCacheNodes: '1'
      #    VpcId: !Ref PubPrivateVPC
          VpcSecurityGroupIds: 
            - !Ref ElasticacheSecurityGroup
      #      - !GetAtt 
      #        - ElasticacheSecurityGroup
      #        - GroupId
    

    【讨论】:

    • 它成功了,谢谢你不能相信我没有看到它,现在我有这个错误:属性VpcSecurityGroupIds的值必须是字符串列表类型。
    • 您的 VpcSecurityGroupIds 必须是一个列表。编辑答案,使属性是一个列表。如果这有帮助,将不胜感激。
    • 我希望我能做到,但我需要 15 名代表才能做到,但非常感谢您的帮助。当我得到它们时,我一定会投赞成票。
    • 现在你明白了;)
    猜你喜欢
    • 2019-07-28
    • 1970-01-01
    • 1970-01-01
    • 2019-09-24
    • 2018-12-15
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多