-
Notifications
You must be signed in to change notification settings - Fork 6
/
hoc.ts
37 lines (35 loc) · 1.35 KB
/
hoc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// Copyright (C) 2019 Dmitry Kolesnikov
//
// This file may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
// https://github.com/fogfish/aws-cdk-pure
//
// Common HoC
import * as acm from '@aws-cdk/aws-certificatemanager'
import * as dns from '@aws-cdk/aws-route53'
import * as cdk from '@aws-cdk/core'
import * as pure from 'aws-cdk-pure'
//
// Lookup AWS Route 53 hosted zone for the domain
export function HostedZone(domainName: string): pure.IPure<dns.IHostedZone> {
const awscdkIssue4592 = (parent: cdk.Construct, id: string, props: dns.HostedZoneProviderProps): dns.IHostedZone => (
dns.HostedZone.fromLookup(parent, id, props)
)
const iaac = pure.include(awscdkIssue4592) // dns.HostedZone.fromLookup
const SiteHostedZone = (): dns.HostedZoneProviderProps => ({ domainName })
return iaac(SiteHostedZone)
}
//
// Issues AWS TLS Certificate for the domain
export function Certificate(site: string, hostedZone: dns.IHostedZone, arn?: string): pure.IPure<acm.ICertificate> {
if (arn) {
const wrap = pure.include(acm.Certificate.fromCertificateArn)
const SiteCA = (): string => arn
return wrap(SiteCA)
} else {
const iaac = pure.iaac(acm.DnsValidatedCertificate)
const SiteCA = (): acm.DnsValidatedCertificateProps => ({ domainName: site, hostedZone })
return iaac(SiteCA)
}
}