gpt4 book ai didi

amazon-web-services - cloudformation : The provided target group has target type instance, 中的 ecs 服务出现问题,与 awsvpc 网络不兼容

转载 作者:行者123 更新时间:2023-12-04 16:29:06 24 4
gpt4 key购买 nike

我正在使用cloudformation创建架构,在创建ECS服务时,出现错误,我的平衡器实例与awsvpc模式不兼容

我尝试了多种方法,但没有一个对我有用,我已经看过 aws 指南,这一切都相应对应,如果可能的话请转到解决方案

"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {

"LoadBalancerQA01": {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"SecurityGroups": [
{
"Ref": "SecurityGroupPublic01"
}
],
"Subnets": [
{
"Ref": "SubnetPublicQATestUno"
},
{
"Ref": "SubnetPublicQATestDos"
}
],
"Name": "LoadBalancerQA01"
}
},
"LoadBalancerListener": {
"Type": "AWS::ElasticLoadBalancingV2::Listener",
"Properties": {
"DefaultActions": [{
"Type": "forward",
"TargetGroupArn": { "Ref": "TargetGroupQA" }
}],
"LoadBalancerArn": { "Ref": "LoadBalancerQA01" },
"Port": 8080,
"Protocol": "HTTP"
}
},
"TargetGroupQA": {
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"Name": "TargetGroupQA",
"Port": 8080,
"Protocol": "HTTP",
"VpcId": { "Ref": "VPCQA" }
},
"DependsOn": [ "LoadBalancerQA01" ]
},
"ClusterQA": {
"Type": "AWS::ECS::Cluster",
"Properties": {},
"DependsOn": [
"SubnetPrivateQATestUno",
"SubnetPrivateQATestDos"
]
},
"TaskQA": {
"Type": "AWS::ECS::TaskDefinition",
"Properties": {
"RequiresCompatibilities": ["FARGATE"],
"Cpu" : "1024",
"TaskRoleArn" : "arn:aws:iam::683574420318:role/ecsTaskExecutionRole",
"ExecutionRoleArn" : "arn:aws:iam::683574420318:role/ecsTaskExecutionRole",
"Memory": "2048",
"NetworkMode" : "awsvpc",
"ContainerDefinitions" : [{
"Image": "683574420318.dkr.ecr.us-west-1.amazonaws.com/mto:latest",
"Cpu": "1024",
"Memory": "2048",
"Name":"ContenedorName",
"PortMappings":[{ "ContainerPort": 8080,"HostPort": 8080}]

}]
}
},
"ServiceQA": {
"Type": "AWS::ECS::Service",
"DependsOn": [ "LoadBalancerQA01" ],
"Properties" : {
"NetworkConfiguration" : {
"AwsvpcConfiguration" : {
"AssignPublicIp" : "ENABLED",
"SecurityGroups" : [
{
"Ref": "SecurityGroupPublic01"
}
],"Subnets": [
{
"Ref": "SubnetPublicQATestUno"
},
{
"Ref": "SubnetPublicQATestDos"
}
]}
},
"Cluster": { "Ref": "ClusterQA" },
"DesiredCount": "1",
"LoadBalancers": [
{
"ContainerName": "ContenedorName",
"ContainerPort": 8080,
"TargetGroupArn": { "Ref": "TargetGroupQA" }
}
],
"TaskDefinition" : {"Ref":"TaskQA"}
}
}

最佳答案

据我所知,您定义的 TargetGroup 没有 TargetType,这意味着默认情况下它设置为 instance。 ECS 服务需要将 TargetType 设置为 ip,这是 awsvpc 支持的唯一选项。在您的 CloudFormation 中只需添加:

"TargetType": "ip",

这应该可以解决您的问题。如果仍然有问题,请从 CloudFormation 控制台提供错误。

关于amazon-web-services - cloudformation : The provided target group has target type instance, 中的 ecs 服务出现问题,与 awsvpc 网络不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55637595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com