{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Parameters": {
    "hostedZoneName": {
      "Type": "String",
      "Description": "The name of the new Hosted Zone to create"
    }
  },

  "Resources": {
    "HostedZone": {
      "Type": "AWS::Route53::HostedZone",
      "Properties": {
        "HostedZoneConfig": {
          "Comment": "Dynamic Hosted Zone"
        },
        "Name": { "Ref": "hostedZoneName" }
      }
    },
    "AcmCertificateForHostedZone": {
      "Type": "AWS::CertificateManager::Certificate",
      "Properties": {
        "DomainName": { "Ref": "hostedZoneName" },
        "SubjectAlternativeNames": [
          { "Fn::Sub": "*.${hostedZoneName}" }
        ],
        "ValidationMethod": "DNS",
        "DomainValidationOptions": [{
          "DomainName": { "Ref": "hostedZoneName" },
          "HostedZoneId": { "Ref": "HostedZone" }
        }]
      }
    }
  }
}
