【问题标题】:Getting error while creating ELB in cloudformation在 cloudformation 中创建 ELB 时出错
【发布时间】:2020-10-20 08:51:31
【问题描述】:
AWSTemplateFormatVersion: 2010-09-09
Resources:
  MyLoadBalancer:
    Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
    Properties:
      IpAddressType: ipv4
      AvailabilityZones:
        - ap-southeast-1
      Name: mytestingELB
      Scheme: internet-facing
      Type: application
      SecurityGroups:
        - !Ref sg-**********
      Subnets:
        - !Ref subnet-******
        - !Ref subnet-*******
      Metadata:
        'AWS::CloudFormation::Designer':
          id: 3f17841f-7296-4aeb-a464-94dbbf6542fd
      'AWS::ElasticLoadBalancingV2::TargetGroup':
        Properties:
          HealthCheckIntervalSeconds: '30'
          HealthCheckPath: /
          HealthCheckProtocol: HTTP
          HealthCheckTimeoutSeconds: '5'
          HealthyThresholdCount: '5'
          Matcher:
            HttpCode: '200'
          Name: testingtargetgroup
          Port: '80'
          Protocol: HTTP
          TargetType: instance
          UnhealthyThresholdCount: '2'
          VpcId: !Ref vpc-******

Getting error Template is not valid: Template format error: Unresolved resource dependencies [subnet-, sg-, subnet- , vpc-*] 在模板的 Resources 块中

请帮我添加

【问题讨论】:

    标签: json amazon-web-services yaml amazon-cloudformation devops


    【解决方案1】:

    如果vpc-******subnet-******sg-********** 是您现有 VPC、子网和安全组的实际 ID,则您不需要!Ref 引用它们。

    只提供不带!Ref 的邮件,例如

    SecurityGroups:
      - sg-**********
    Subnets:
      - subnet-******
      - subnet-*******
    
    VpcId: vpc-******
    

    新模板版本:

    AWSTemplateFormatVersion: 2010-09-09
    Resources:
      MyLoadBalancer:
        Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
        Properties:
          IpAddressType: ipv4
          Name: mytestingELB
          Scheme: internet-facing
          Type: application
          SecurityGroups:
            - !Ref sg-**********
          Subnets:
            - !Ref subnet-******
            - !Ref subnet-*******
    
      MyTargetGroup
          'AWS::ElasticLoadBalancingV2::TargetGroup':
            Properties:
              HealthCheckIntervalSeconds: '30'
              HealthCheckPath: /
              HealthCheckProtocol: HTTP
              HealthCheckTimeoutSeconds: '5'
              HealthyThresholdCount: '5'
              Matcher:
                HttpCode: '200'
              Name: testingtargetgroup
              Port: '80'
              Protocol: HTTP
              TargetType: instance
              UnhealthyThresholdCount: '2'
              VpcId: !Ref vpc-******
    

    添加了MyTargetGroup,删除了AvailabilityZonesMetadata

    【讨论】:

    • 谢谢@Marcin 现在我在创建这个时遇到了两个错误遇到不支持的属性AvailabilityZones 无法创建以下资源:[MyLoadBalancer]。 .用户请求回滚
    • @shubhamkamboj 该模板还有许多其他问题。很难同时解决所有这些问题。也许检查模板的来源。它可能被错误地复制或修改。我会修改答案。
    • 显示模板错误。实际上,我的目标是使用 ELB 创建自动缩放。因此,如果您有任何用于创建自动缩放的模板。你能把这个寄给我吗?我是云的新手。
    • @shubhamkamboj 遗憾的是,您的请求是特定于应用程序和用例的,而我没有通用模板。我的建议是查看 ASG 示例 here 以及 aws here 提供的示例模板。它们是创建您自己的模板的良好开端。另外,如果我的回答有帮助,我们将不胜感激。
    • @shubhamkamboj 没问题。希望它会成功。如果您将来有问题,请随时提出新问题。
    猜你喜欢
    • 1970-01-01
    • 2017-07-15
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-14
    • 2014-02-02
    • 2017-06-11
    • 1970-01-01
    相关资源
    最近更新 更多