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 réponse
0
Réponse acceptée

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
répondu il y a 5 mois
profile picture
EXPERT
vérifié il y a 5 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions