我想使用 AWS CloudFormation 将多个 AWS Certificate Manager SSL 和 TLS 证书与 Application Load Balancer 关联起来。
简短描述
要为安全侦听器添加默认 SSL 服务器,请使用资源 AWS::ElasticLoadBalancingV2::Listener 的 Certificates(证书)属性。此资源提供一个证书。要添加更多证书,请使用 AWS::ElasticLoadBalancingV2::ListenerCertificate。AWS::ElasticLoadBalancingV2::ListenerCertificate 包含接受证书列表的 Certificates(证书)参数。
解决方法
使用以下 CloudFormation 模板创建带有一个默认证书的 Application Load Balancer 侦听器:
HTTPlistener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
DependsOn: ApplicationLoadBalancer
Properties:
DefaultActions:
- Type: fixed-response
FixedResponseConfig:
ContentType: text/plain
MessageBody: Success
StatusCode: '200'
LoadBalancerArn: >-
arn:aws:elasticloadbalancing:<Region>:<AccountID>:loadbalancer/app/TestACMELB/1032d48308c9b37f
Port: '443'
Protocol: HTTPS
Certificates:
- CertificateArn: >-
arn:aws:acm:<Region>:<AccountID>:certificate/cffb8a69-0817-4e04-bfb1-dac7426d6b90
使用以下 CloudFormation 模板向 Application Load Balancer 侦听器添加多个证书:
AdditionalCertificates:
Type: 'AWS::ElasticLoadBalancingV2::ListenerCertificate'
DependsOn: HTTPlistener
Properties:
Certificates:
- CertificateArn: >-
arn:aws:acm:<Region>:<AccountID>:certificate/c71a3c29-e79d-40e6-8834-650fe0d54a3f
- CertificateArn: >-
arn:aws:acm:<Region>:<AccountID>:certificate/fff1c1ba-3d97-4735-b3d5-9c5269b75db3
ListenerArn:
Ref: HTTPlistener