farwardtotargetgroup:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
Certificates:
- CertificateArn: !Ref cert
DefaultActions:
- TargetGroupArn: !Ref target-group
Type: forward
LoadBalancerArn: !Ref nlb
Port: 443
Protocol: TLS
redirectto443:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- RedirectConfig:
Port: 443
StatusCode: HTTP_301
Type: redirect
LoadBalancerArn: !Ref nlb
Port: 80
Protocol: TLS
当我执行模板时,我得到:
操作类型"重定向"对网络负载均衡器无效(服务:AmazonElasticLoadBalancingV2;状态代码:400;错误代码:无效负载均衡器操作;
重定向规则仅支持应用程序负载均衡器,不支持网络负载均衡器。
如果可以为应用程序使用应用程序负载均衡器,则可以使用它。
从文档
[应用程序负载均衡器] 有关创建重定向操作的信息。 仅在"类型"为重定向时指定。