AWS ACM不支持为同一域名颁发多个证书。但是,可以使用AWS Elastic Load Balancer(ELB)为同一个域名使用多个证书。以下是一个示例:
1.创建两个ACM证书,分别用于验证该域名的不同内容。
2.将这两个证书附加到同一个ELB。
3.设置ELB以接受所有连接并根据请求中的Host头将其转发到适当的后端。
以下是用于创建ELB的CloudFormation模板示例:
Resources:
MyELB:
Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
Properties:
Name: my-elb
Subnets:
- subnet-xxxxxx
- subnet-yyyyyy
SecurityGroups: [ sg-1234abcd ]
Type: network
Scheme: internet-facing
LoadBalancerAttributes:
- Key: idle_timeout.timeout_seconds
Value: '60'
Tags:
- Key: Name
Value: my-elb
HTTPListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
DependsOn: MyELB
Properties:
LoadBalancerArn: !Ref MyELB
Port: 80
Protocol: TCP
DefaultActions:
- Type: fixed-response
FixedResponseConfig:
ContentType: 'text/plain'
MessageBody: 'Hello, world!'
StatusCode: '200'
HTTPSListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
DependsOn: MyELB
Properties:
LoadBalancerArn: !Ref MyELB
Port: 443
Protocol: TCP
Certificates:
- CertificateArn: "arn:aws:acm:us-west-2:123456789012:certificate/xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbcccc"
- CertificateArn: "arn:aws:acm:us-west-2:123456789012:certificate/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"