@aws-cdk/core#IDependable TypeScript Examples
The following examples show how to use
@aws-cdk/core#IDependable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: auth-stack.ts From MDDL with MIT License | 5 votes |
/**
* Set the Hosted UI custom domain for a user pool
* @param userPool The user pool to configure
* @param customDomain Details on the custom domain to configure
*/
private addCustomDomain(
userPool: UserPool,
customDomain: CustomHostedDomain,
uiCustomization?: CfnUserPoolUICustomizationAttachment,
) {
// read out configuration
const {
domain,
certificateArn,
shouldCreateRootARecord,
hostedZoneAttributes,
} = customDomain
const dependencies: IDependable[] = []
// create reference to hosted zone
const hostedZone = HostedZone.fromHostedZoneAttributes(
this,
`HostedZone`,
hostedZoneAttributes,
)
// add root A record if needed
if (shouldCreateRootARecord) {
const rootDomain = domain.split('.', 1)[1]
const rootDomainBucket = new Bucket(this, 'RootHostingBucket', {
bucketName: rootDomain,
publicReadAccess: true,
websiteRedirect: {
hostName: domain,
protocol: RedirectProtocol.HTTPS,
},
})
const rootAliasRecord = new ARecord(this, `RootAliasRecord`, {
zone: hostedZone,
recordName: rootDomain,
target: RecordTarget.fromAlias(
new BucketWebsiteTarget(rootDomainBucket),
),
})
rootAliasRecord.node.addDependency(rootDomainBucket)
dependencies.push(rootAliasRecord)
}
// get reference to cerificate
const certificate = Certificate.fromCertificateArn(
this,
`UserPoolCertificate`,
certificateArn,
)
// add domain to user pool
const userPoolDomain = userPool.addDomain('HostedDomain', {
customDomain: {
certificate,
domainName: domain,
},
})
userPoolDomain.node.addDependency(...dependencies)
// create A record for custom domain
const aRecord = new ARecord(this, `CustomDomainAliasRecord`, {
zone: hostedZone,
recordName: domain,
target: RecordTarget.fromAlias(
new MinimalCloudFrontTarget(this, userPoolDomain.cloudFrontDomainName),
),
})
if (uiCustomization) {
uiCustomization.addDependsOn(aRecord.node.defaultChild as CfnRecordSet)
}
}