Skip to content

Commit

Permalink
Merge pull request #2058 from vrk-kpa/AV-2058_add_new_domain_zone
Browse files Browse the repository at this point in the history
AV-2058: Add new domain to route53
  • Loading branch information
Zharktas authored Oct 4, 2023
2 parents 652f2f6 + 73620f9 commit 52f6660
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cdk/bin/opendata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {CertificateStack} from "../lib/certificate-stack";
import {BypassCdnStack} from "../lib/bypass-cdn-stack";
import {MonitoringStack} from "../lib/monitoring-stack";
import {LambdaStack} from "../lib/lambda-stack";
import {DomainStack} from "../lib/domain-stack";
import {CiTestStack} from "../lib/ci-test-stack";

// load .env file, shared with docker setup
Expand Down Expand Up @@ -376,6 +377,7 @@ const prodProps = {
secondaryFqdn: 'opendata.fi',
domainName: 'www.avoindata.fi',
secondaryDomainName: 'www.opendata.fi',
newDomainName: "avoindata.suomi.fi"
};

const clusterStackProd = new ClusterStack(app, 'ClusterStack-prod', {
Expand Down Expand Up @@ -687,6 +689,10 @@ const monitoringStackProd = new MonitoringStack(app, 'MonitoringStack-prod', {
secondaryDomainName: prodProps.secondaryDomainName,
});

const domainStackProd = new DomainStack(app, 'DomainStack-prod', {
zoneName: prodProps.newDomainName,
crossAccountId: betaProps.account
})

const ciTestStackBeta = new CiTestStack(app, 'CiTestStack-beta', {
env: {
Expand Down
6 changes: 6 additions & 0 deletions cdk/lib/domain-stack-props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {StackProps} from "aws-cdk-lib";

export interface DomainStackProps extends StackProps{
crossAccountId?: string,
zoneName: string
}
25 changes: 25 additions & 0 deletions cdk/lib/domain-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import {aws_iam, aws_route53} from "aws-cdk-lib";
import {DomainStackProps} from "./domain-stack-props";

export class DomainStack extends cdk.Stack {
readonly publicZone: aws_route53.PublicHostedZone;
constructor(scope: Construct, id: string, props: DomainStackProps) {
super(scope, id, props);

this.publicZone = new aws_route53.PublicHostedZone(this, "HostedZone", {
zoneName: props.zoneName,
})


if (props.crossAccountId) {
const role = new aws_iam.Role(this, 'Route53CrossDelegateRole', {
assumedBy: new aws_iam.AccountPrincipal(props.crossAccountId),
roleName: "Route53CrossDelegateRole"
})

this.publicZone.grantDelegation(role)
}
}
}

0 comments on commit 52f6660

Please sign in to comment.