Last active
May 22, 2022 22:08
-
-
Save SlootSantos/28b486b780b91066b7266e0bef2c46aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Construct } from "constructs"; | |
import { CfnOutput, Stack, StackProps } from "aws-cdk-lib"; | |
import { buildDelegatedDomainHostedZone } from "../services/Route53/delegatedDomainHostedZone"; | |
import { buildDelegatedNameServerRecord } from "../services/CustomResources/delegatedNameServerRecord"; | |
import { domains } from "../constants/domains"; | |
interface DelegatedDomainStackProps extends StackProps { | |
stageConfig: { | |
stage: "dev" | "prod"; | |
}; | |
} | |
export class DelegatedDomainStack extends Stack { | |
delegatedSubdomain: CfnOutput; | |
delegatedNameServers: CfnOutput; | |
constructor(scope: Construct, id: string, props: DelegatedDomainStackProps) { | |
super(scope, id, props); | |
const hostedZone = buildDelegatedDomainHostedZone( | |
this, | |
props.stageConfig.stage | |
); | |
const delegatedNameServerList = buildDelegatedNameServerRecord( | |
this, | |
props.stageConfig.stage, | |
hostedZone | |
); | |
this.delegatedNameServers = new CfnOutput(this, "DelegatedNameServers", { | |
// we use this format with the space delimiter as we're using it sanity test script as well | |
value: delegatedNameServerList.join(" "), | |
}); | |
this.delegatedSubdomain = new CfnOutput(this, "DelegatedSubdomain", { | |
// we use this format with the space delimiter as we're using it sanity test script as well | |
value: `${props.stageConfig.stage}.${domains.root}`, | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Construct } from "constructs"; | |
import { HostedZone } from "aws-cdk-lib/aws-route53"; | |
import { domains } from "../../constants/domains"; | |
export const buildDelegatedDomainHostedZone = ( | |
scope: Construct, | |
subdomain: string | |
) => { | |
const zone = new HostedZone(scope, "DelegatedDomainHostedZone", { | |
zoneName: `${subdomain}.${domains.root}`, | |
}); | |
return zone; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment