Amazon cloudformation 在Cloudformation中创建应用程序负载平衡器时出错。。。XXXXX必须为ARN格式
使用AWS CloudFormation服务,我试图在2个EC2实例上创建应用程序弹性负载平衡器,但在创建侦听器[AWS::ElasticLoadBalancingV2::Listener]时出错,如下所示: “AELB-ElasticLoadBa-XDTNTTXRZMC8'必须为ARN格式(服务:AmazonElasticLoadBalancingV2;状态代码:400;错误代码:ValidationError;请求ID:9b18bb79-9e58-11e8-9b70-c9b2be714e80)” 我已经参考了aws代码模板并添加了以下代码,我是否遗漏了什么Amazon cloudformation 在Cloudformation中创建应用程序负载平衡器时出错。。。XXXXX必须为ARN格式,amazon-cloudformation,aws-elb,Amazon Cloudformation,Aws Elb,使用AWS CloudFormation服务,我试图在2个EC2实例上创建应用程序弹性负载平衡器,但在创建侦听器[AWS::ElasticLoadBalancingV2::Listener]时出错,如下所示: “AELB-ElasticLoadBa-XDTNTTXRZMC8'必须为ARN格式(服务:AmazonElasticLoadBalancingV2;状态代码:400;错误代码:ValidationError;请求ID:9b18bb79-9e58-11e8-9b70-c9b2be714e80
ElasticLoadBalancer:
Type: 'AWS::ElasticLoadBalancing::LoadBalancer'
Properties:
Instances: [!Ref 'webServer1', !Ref 'webServer2']
CrossZone: 'true'
Listeners:
- LoadBalancerPort: '80'
InstancePort: '80'
Protocol: HTTP
Subnets:
- !Ref pubSubnet
SecurityGroups:
- !Ref LoadBalancerSecurityGroup
HealthCheck:
Target: HTTP:80/
HealthyThreshold: '3'
UnhealthyThreshold: '5'
Interval: '30'
Timeout: '5'
TargetGroupService1:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
Name:
'Fn::Join':
- '-'
- - Ref: 'AWS::StackName'
- 'TargetGroupService1'
Port: 10
Protocol: HTTP
#HealthCheckPath: /service1
Targets:
- Id:
Ref: webServer1
Port: 80
VpcId: !Ref myDemoVPC
TargetGroupService2:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
Name:
'Fn::Join':
- '-'
- - Ref: 'AWS::StackName'
- 'TargetGroupService2'
Port: 10
Protocol: HTTP
#HealthCheckPath: /service2
Targets:
- Id:
Ref: webServer2
Port: 80
VpcId: !Ref myDemoVPC
Listener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref TargetGroupService1
LoadBalancerArn: !Ref ElasticLoadBalancer
Port: '80'
Protocol: HTTP
ListenerRuleService1:
Type: 'AWS::ElasticLoadBalancingV2::ListenerRule'
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref TargetGroupService1
Conditions:
- Field: path-pattern
Values:
- "/service1"
ListenerArn: !Ref Listener
Priority: 1
ListenerRuleService2:
Type: 'AWS::ElasticLoadBalancingV2::ListenerRule'
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref TargetGroupService2
Conditions:
- Field: path-pattern
Values:
- "/service2"
ListenerArn: !Ref Listener
Priority: 2
您使用了错误的云信息资源。应用程序负载平衡器的
类型是AWS::ElasticLoadBalancev2::LoadBalancer
。注意V2
。您正在使用的一个创建了一个经典的负载平衡器
您得到的错误是由于经典LB和应用LB之间Ref
函数的返回值不同造成的
当您指定:
LoadBalancerArn:!Ref弹性负载平衡器
Ref
Classic LB返回资源名称(AELB-ElasticLoadBa-XDTNTTXRZMC8),而Ref
ALB返回资源Arn,这是V2侦听器对LoadBalancerArn
属性的期望
使用具有所述适当属性的V2负载平衡器替换逻辑名称为ElasticLoadBalancer的资源应该可以解决您的问题。@Smi很高兴它能工作。如果您觉得我的回答有助于解决您的问题,您可以接受:)