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'

1 Antwort
0
Akzeptierte Antwort

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
beantwortet vor 5 Monaten
profile picture
EXPERTE
überprüft vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen