How do I assign multiple domains to a certificate created using cloudformation

0

When manually creating a certificate using the console, I can add multiple domain names, so I get a cert for "example.com" as well as "*.example.com". The certificate arn is to be used by a Cloudfront distribution for an S3 backed site.

How do I do this using cloudformation? or does this have to be a manual step?

Parameters:
  RootDomainName:
    Description: Domain name for your website (example.com)
    Type: String
  HostedZoneId:
    Description: The route53 zone id of the domain
    Type: String

Resources:
  SiteCert:
    Type: AWS::CertificateManager::Certificate
    Properties:
      DomainName: !Ref RootDomainName   # + *.RootDomainName
      DomainValidationOptions:
        - DomainName: !Ref RootDomainName
          HostedZoneId: !Ref HostedZoneId
      ValidationMethod: 'DNS'

Shane
已提问 5 个月前289 查看次数
1 回答
0
已接受的回答

I found the answer - you set SubjectAlternativeNames to add the extra names to the cert.

Resources:
  SiteCert:
    Type: AWS::CertificateManager::Certificate
    Properties:
      DomainName: !Ref RootDomainName
      DomainValidationOptions:
        - DomainName: !Ref RootDomainName
          HostedZoneId: !Ref HostedZoneId
      SubjectAlternativeNames:
        - !Sub
          - www.${Domain}
          - Domain: !Ref RootDomainName
      ValidationMethod: 'DNS'
Shane
已回答 5 个月前
profile picture
专家
已审核 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则