https://pulumi.com logo
Title
a

astonishing-tiger-81216

07/22/2021, 2:01 PM
Is something like this possible with pulumi?
const orgCertificate = new acm.Certificate('org-certificate', {
    domainName: orgZone.name,
    validationMethod: 'DNS'
})

let validationRecords: pulumi.Output<string>[] = []

for (let i in orgCertificate.domainValidationOptions) {
    validationRecords.push(
        new route53.Record(`org-validation-record-${i}`, {
            name: orgCertificate.domainValidationOptions[i].resourceRecordName,
            type: orgCertificate.domainValidationOptions[i].resourceRecordType,
            records: [ orgCertificate.domainValidationOptions[i].resourceRecordValue ],
            zoneId: orgZone.zoneId,
            ttl: 60,
            allowOverwrite: true
        }).fqdn
    )
}

new acm.CertificateValidation('org-certificate-validation', {
    certificateArn: orgCertificate.arn,
    validationRecordFqdns: validationRecords
})
I get this error:
error: Running program '/Users/mallison/workspace/gdsgroup/equiv/immersify' failed with an unhandled exception:
    Error: Missing required property 'name'
at new Record (/Users/MYNAME/workspace/DIR/DIR/DIR/node_modules/@pulumi/route53/record.ts:246:23)
āœ… 1
w

witty-candle-66007

07/22/2021, 2:13 PM
My gut feeling is that when creating the `route53.Record`the
orgCertificate.domain.ValidationOptions[i].resoruceRecordName
is undefined. So, using
apply()
to reconcile the promise should fix that. Try changing the
name
property setting to the following:
name: orgCertificate.domainValidationOptions[i].resourceRecordName.apply(resourceRecordName => resourceRecordName)
More discussion of these concepts can be found here: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/# And here: https://www.leebriggs.co.uk/blog/2021/05/09/pulumi-apply.html
a

astonishing-tiger-81216

07/22/2021, 4:23 PM
Hi @witty-candle-66007 I tried the following:
name: orgCertificate.domainValidationOptions.apply(domainValidationOptions => domainValidationOptions)[i].resourceRecordName

 error: Running program '/Users/mallison/workspace/gdsgroup/immersify' failed with an unhandled exception:
    Error: Missing required property 'name'
        at new Record (/Users/mallison/workspace/gdsgroup/immersify/node_modules/@pulumi/route53/record.ts:246:23)
Your suggestion:
name: orgCertificate.domainValidationOptions[i].resourceRecordName.apply(resourceRecordName => resourceRecordName)

error: Running program '/Users/mallison/workspace/gdsgroup/immersify' failed with an unhandled exception:
    TypeError: Cannot read property 'apply' of undefined
And finally:
name: orgCertificate.domainValidationOptions.apply(domainValidationOptions => domainValidationOptions[i].resourceRecordName)
Which worked šŸ‘ Thanks for your help on this
w

witty-candle-66007

07/22/2021, 4:30 PM
Iā€™m glad you were able to work past my incorrect example. šŸ™‚