forked from oxheadalpha/teztnets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
route53.ts
50 lines (47 loc) · 1.36 KB
/
route53.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
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as aws from "@pulumi/aws"
import * as pulumi from "@pulumi/pulumi"
// based on code from tqinfra
export function createCertValidation(
{
cert,
targetDomain,
hostedZone,
}: { cert: aws.acm.Certificate; targetDomain: string; hostedZone: aws.route53.Zone },
opts = {}
) {
// certRecords won't show up in `pulumi preview` but will in `pulumi up`. This
// is because certRecords is waiting for async data via the `apply` function.
const certRecords = cert.domainValidationOptions.apply(
(domainValidations) => {
return domainValidations.map(
(domainValidation) =>
new aws.route53.Record(
`${domainValidation.domainName}-certValidationRecord`,
{
name: domainValidation.resourceRecordName,
records: [domainValidation.resourceRecordValue],
ttl: 300,
type: domainValidation.resourceRecordType,
zoneId: hostedZone.id,
},
{
...opts,
}
)
)
}
)
const certValidation = new aws.acm.CertificateValidation(
`${targetDomain}-certValidation`,
{
certificateArn: cert.arn,
validationRecordFqdns: certRecords.apply((records) =>
records.map((record) => record.fqdn)
),
},
{
...opts,
}
)
return { certRecords, certValidation }
}