AWSTemplateFormatVersion: 2010-09-09

Parameters:
  # Must specify parameters by passing `--paramters` flag into cloudformation
  # E.g. ParameterKey=<KeyName>,ParameterValue="<KeyValue>"
  DomainName:
    Type: String
    Description: '(sub)Domain name e.g. (foo.)example.com'

  VerificationDomain:
    Type: String
    Description: 'Verification domain e.g. example.com'

  VerificationMethod:
    Type: String
    AllowedValues:
      - 'EMAIL'
      - 'DNS'
    Default: 'EMAIL'
    Description: 'Domain verification method'

Resources:
  zbCertificate:
    Type: AWS::CertificateManager::Certificate
    Properties:
       DomainName:
         Ref: DomainName
       SubjectAlternativeNames:
         - !Join ['', ['www.', Ref: DomainName]]
       ValidationMethod: !Ref VerificationMethod
       DomainValidationOptions:
          - DomainName:
              Ref: DomainName
            ValidationDomain:
              Ref: VerificationDomain

Outputs:
  CertArn:
    Value: !Ref zbCertificate
    Description: 'Certificate ARN'