-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2069 from vrk-kpa/AV-2058_add_subdomain_stack_for…
…_beta_environment AV-2058: Add subdomain stack for beta environment
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {aws_route53, StackProps} from "aws-cdk-lib"; | ||
import {ApplicationLoadBalancer} from "aws-cdk-lib/aws-elasticloadbalancingv2"; | ||
|
||
export interface SubDomainStackProps extends StackProps { | ||
prodAccountId: string; | ||
subDomainName: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {aws_iam, aws_route53, aws_route53_targets, Stack} from "aws-cdk-lib"; | ||
import {Construct} from "constructs"; | ||
import {SubDomainStackProps} from "./sub-domain-stack-props"; | ||
|
||
export class SubDomainStack extends Stack { | ||
readonly subZone: aws_route53.PublicHostedZone; | ||
readonly newSubZone: aws_route53.PublicHostedZone; | ||
constructor(scope: Construct, id: string, props: SubDomainStackProps) { | ||
super(scope, id, props); | ||
|
||
this.subZone = new aws_route53.PublicHostedZone(this, 'SubZone', { | ||
zoneName: props.subDomainName + ".avoindata.suomi.fi" | ||
}) | ||
|
||
const delegationRoleArn = Stack.of(this).formatArn({ | ||
region: '', | ||
service: 'iam', | ||
account: props.prodAccountId, | ||
resource: 'role', | ||
resourceName: 'Route53CrossDelegateRole' | ||
}) | ||
|
||
const delegationRole = aws_iam.Role.fromRoleArn(this, 'delegationRole', delegationRoleArn) | ||
|
||
new aws_route53.CrossAccountZoneDelegationRecord(this, 'delegate', { | ||
delegatedZone: this.subZone, | ||
delegationRole: delegationRole, | ||
parentHostedZoneName: "avoindata.suomi.fi" | ||
}) | ||
|
||
} | ||
|
||
} |