Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services Cloudformation应用程序负载平衡器弹性IP错误_Amazon Web Services_Amazon Cloudformation_Aws Load Balancer - Fatal编程技术网

Amazon web services Cloudformation应用程序负载平衡器弹性IP错误

Amazon web services Cloudformation应用程序负载平衡器弹性IP错误,amazon-web-services,amazon-cloudformation,aws-load-balancer,Amazon Web Services,Amazon Cloudformation,Aws Load Balancer,我正在尝试用Cloudformation自动化一个由一个Fargate集群、多个服务和一个应用程序负载平衡器组成的堆栈 不幸的是,LoadBalancer的创建失败,并显示以下错误消息:“类型为“application”的负载平衡器不支持弹性IP” 我知道弹性IP不受支持,但我不明白为什么Cloudformation会尝试将弹性IP分配给我的负载平衡器。我在参考资料中没有发现关于某个值默认为弹性IP分配的提示 "Resources": { "Cluster": { "Type

我正在尝试用Cloudformation自动化一个由一个Fargate集群、多个服务和一个应用程序负载平衡器组成的堆栈

不幸的是,LoadBalancer的创建失败,并显示以下错误消息:“类型为“application”的负载平衡器不支持弹性IP”

我知道弹性IP不受支持,但我不明白为什么Cloudformation会尝试将弹性IP分配给我的负载平衡器。我在参考资料中没有发现关于某个值默认为弹性IP分配的提示

"Resources": {
    "Cluster": {
      "Type": "AWS::ECS::Cluster",
      "Properties": {}
    },
    "Service": {
      "Type": "AWS::ECS::Service",
      "Properties": {
        "Cluster": {
          "Ref": "Cluster"
        },
        "TaskDefinition": {
          "Ref": "Task"
        },
        "LoadBalancers": [
          {
            "ContainerName": "service1",
            "ContainerPort": 80,
            "LoadBalancerName": {
              "Ref": "LoadBalancer"
            },
            "TargetGroupArn": {
              "Ref": "TargetGroup"
            }
          }
        ],
        "NetworkConfiguration": {
          "AwsvpcConfiguration": {
            "AssignPublicIp": "false",
            "Subnets": [
              {
                "Ref": "Subnet1"
              },
              {
                "Ref": "Subnet2"
              }
            ]
          }
        }
      }
    },
    "Task": {
      "Type": "AWS::ECS::TaskDefinition",
      "Properties": {
        "ContainerDefinitions": [
          {
            "PortMappings": [
              {
                "HostPort": 80,
                "Protocol": "tcp",
                "ContainerPort": 80
              }
            ],
            "Environment": [
              {
                "Name": "SERVER_PORT",
                "Value": "80"
              }
            ],
            "Image": "arn",
            "Essential": true,
            "Name": "service1",
            "Memory": 2048
          }
        ],
        "TaskRoleArn": "arn",
        "NetworkMode": "awsvpc"
      }
    },

    "LoadBalancer": {
      "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
      "Properties": {
        "SubnetMappings": [
          {
            "SubnetId": {
              "Ref": "Subnet1"
            },
            "AllocationId": "subnet-1"
          },
          {
            "SubnetId": {
              "Ref": "Subnet2"
            },
            "AllocationId": "subnet-2"
          }
        ],
        "SecurityGroups": [
          {
            "Ref": "VPCSecurityGroup"
          }
        ]
      }
    },
    "VPC": {
      "Type": "AWS::EC2::VPC",
      "Properties": {
        "CidrBlock": "10.0.0.0/16"
      }
    },
    "VPCSecurityGroup": {
      "Type": "AWS::EC2::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "VPC"
        },
        "GroupDescription": "security group"
      }
    },
    "Subnet1": {
      "Type": "AWS::EC2::Subnet",
      "Properties": {
        "VpcId": {
          "Ref": "VPC"
        },
        "CidrBlock": "10.0.0.0/24",
        "MapPublicIpOnLaunch": false
      }
    },
    "Subnet2": {
      "Type": "AWS::EC2::Subnet",
      "Properties": {
        "VpcId": {
          "Ref": "VPC"
        },
        "CidrBlock": "10.0.1.0/24",
        "MapPublicIpOnLaunch": false
      }
    },
    "Listener": {
      "Type": "AWS::ElasticLoadBalancingV2::Listener",
      "Properties": {
        "LoadBalancerArn": {
          "Ref": "LoadBalancer"
        },
        "DefaultActions": [
          {
            "Type": "FORWARD"
          }
        ],
        "Port": 443,
        "Protocol": "HTTPS",
        "Certificates": [
          {
            "CertificateArn": "arn"
          }
        ]
      }
    },
    "TargetGroup": {
      "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
      "Properties": {
        "VpcId": {
          "Ref": "VPC"
        },
        "Port": 80,
        "Protocol": "HTTP"
      }
    },
    "ListenerRule": {
      "Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
      "Properties": {
        "Actions": [
          {
            "Type": "FORWARD"
          }
        ],
        "Priority": 1,
        "Conditions": [],
        "ListenerArn": {
          "Ref": "Listener"
        }
      }
    }


我通过删除SubnetMappings属性并声明Subnets属性修复了弹性IP错误

  "LoadBalancer": {
            "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
            "Properties": {
                "Subnets": [
                    {

                      "Ref": "PublicSubnet1"

                    },
                    {

                      "Ref": "PublicSubnet2"

                    }
                ],
                "SecurityGroups": [
                    {
                        "Ref": "VPCSecurityGroup"
                    }
                ]
            }
    }


这就是你的全部剧本吗?我没有看到任何导致上述错误的原因。我编辑了脚本,将集群、服务和任务描述也包括在内。