"elb name longer than 32" 但只有 8 个
"elb name longer than 32" but only 8
我正在尝试使用 AWS cloudformation 创建一个带有 ALB 和 ECS 服务的堆栈,但我在 AWS::ECS::Service
上得到一个 CREATE_FAILED
,即 elb name longer than 32
。
我不明白为什么 ECS 服务在 ALB 本身处于 CREATE_COMPLETE
状态时抱怨 ELB 名称…
这是与我发送到 cloudformation 的 ALB 创建相关的 JSON:
"loadBalancer" : {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"Name": "test-alb",
"Scheme" : "internal",
"Subnets" : [
"subnet-b8217295",
"subnet-ddaad2b8",
"subnet-6d71fb51"
],
"LoadBalancerAttributes" : [
{ "Key" : "idle_timeout.timeout_seconds", "Value" : "50" }
],
"SecurityGroups": [
{ "Ref": "InstanceSecurityGroupOpenWeb" },
{ "Ref" : "InstanceSecurityGroupOpenFull" }
],
"Tags" : [
{ "Key" : "key", "Value" : "value" },
{ "Key" : "key2", "Value" : "value2" }
]
}
}
这是与 ECS 服务创建相关的 JSON(引用上面定义的 ALB):
"EcsService": {
"Type":"AWS::ECS::Service",
"Properties":{
"Cluster":{
"Ref": "EcsCluster"
},
"DesiredCount":"1",
"DeploymentConfiguration":{
"MaximumPercent":100,
"MinimumHealthyPercent":0
},
"LoadBalancers": [
{
"ContainerName": "test-web",
"ContainerPort":"80",
"LoadBalancerName":{
"Ref": "loadBalancer"
}
}
],
"Role":{
"Ref": "EcsServiceRole"
},
"TaskDefinition":{
"Ref": "runWebServerTaskDefinition"
}
}
}
正如你所见,我自己设置了 ALB 的名称,它只有 8 个字符,所以我真的不明白,你知道吗?
当您执行 "Ref" 时,它会 return 负载均衡器 ARN 而不是负载均衡器名称。您需要使用 GetAtt 获取负载均衡器名称
{ "Fn::GetAtt" : [ "loadBalancer", "LoadBalancerName" ] }
我正在尝试使用 AWS cloudformation 创建一个带有 ALB 和 ECS 服务的堆栈,但我在 AWS::ECS::Service
上得到一个 CREATE_FAILED
,即 elb name longer than 32
。
我不明白为什么 ECS 服务在 ALB 本身处于 CREATE_COMPLETE
状态时抱怨 ELB 名称…
这是与我发送到 cloudformation 的 ALB 创建相关的 JSON:
"loadBalancer" : {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"Name": "test-alb",
"Scheme" : "internal",
"Subnets" : [
"subnet-b8217295",
"subnet-ddaad2b8",
"subnet-6d71fb51"
],
"LoadBalancerAttributes" : [
{ "Key" : "idle_timeout.timeout_seconds", "Value" : "50" }
],
"SecurityGroups": [
{ "Ref": "InstanceSecurityGroupOpenWeb" },
{ "Ref" : "InstanceSecurityGroupOpenFull" }
],
"Tags" : [
{ "Key" : "key", "Value" : "value" },
{ "Key" : "key2", "Value" : "value2" }
]
}
}
这是与 ECS 服务创建相关的 JSON(引用上面定义的 ALB):
"EcsService": {
"Type":"AWS::ECS::Service",
"Properties":{
"Cluster":{
"Ref": "EcsCluster"
},
"DesiredCount":"1",
"DeploymentConfiguration":{
"MaximumPercent":100,
"MinimumHealthyPercent":0
},
"LoadBalancers": [
{
"ContainerName": "test-web",
"ContainerPort":"80",
"LoadBalancerName":{
"Ref": "loadBalancer"
}
}
],
"Role":{
"Ref": "EcsServiceRole"
},
"TaskDefinition":{
"Ref": "runWebServerTaskDefinition"
}
}
}
正如你所见,我自己设置了 ALB 的名称,它只有 8 个字符,所以我真的不明白,你知道吗?
当您执行 "Ref" 时,它会 return 负载均衡器 ARN 而不是负载均衡器名称。您需要使用 GetAtt 获取负载均衡器名称
{ "Fn::GetAtt" : [ "loadBalancer", "LoadBalancerName" ] }