From c34d28391b01efe9132634fb9ba8fe1729b0e47f Mon Sep 17 00:00:00 2001 From: "james.eastham" Date: Tue, 3 Feb 2026 17:32:16 +0000 Subject: [PATCH] fix: resolve issues with DNS parsing --- shared/infra/aws/lib/dns.ts | 5 +++-- shared/infra/aws/lib/network.ts | 2 +- shared/infra/aws/lib/shared-resources-stack.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/shared/infra/aws/lib/dns.ts b/shared/infra/aws/lib/dns.ts index f3b4039b..3fffb0a7 100644 --- a/shared/infra/aws/lib/dns.ts +++ b/shared/infra/aws/lib/dns.ts @@ -34,19 +34,20 @@ export class Dns extends Construct { "ImportedCertificate", certificateArn, ); + } else { this.certificate = undefined; this.hostedZone = undefined; } } - addCnameFor(distribution: Distribution) { + addCnameFor(distribution: Distribution, env: string) { // Add a CName if the hosted zone exists. if (this.hostedZone) { const cNameRecord = new CnameRecord(this, "CnameRecord", { zone: this.hostedZone!, domainName: distribution.domainName, - recordName: this.getPrimaryDomainName("prod")!, + recordName: this.getPrimaryDomainName(env)!, ttl: Duration.minutes(5), }); } diff --git a/shared/infra/aws/lib/network.ts b/shared/infra/aws/lib/network.ts index 691213c8..c234f35e 100644 --- a/shared/infra/aws/lib/network.ts +++ b/shared/infra/aws/lib/network.ts @@ -161,7 +161,7 @@ export class Network extends Construct { comment: `OAI for stickerlandia web frontend ${props.env}`, }); webFrontendBucket.grantRead(originIdentity); - + this.distribution = new Distribution(this, `Stickerlandia-${props.env}`, { certificate: props.dns.certificate, domainNames: props.dns.getPrimaryDomainName(props.env) diff --git a/shared/infra/aws/lib/shared-resources-stack.ts b/shared/infra/aws/lib/shared-resources-stack.ts index b69a02e8..b504ba0f 100644 --- a/shared/infra/aws/lib/shared-resources-stack.ts +++ b/shared/infra/aws/lib/shared-resources-stack.ts @@ -31,7 +31,7 @@ export class StickerlandiaSharedResourcesStack extends cdk.Stack { dns: dns, }); - dns.addCnameFor(network.distribution); + dns.addCnameFor(network.distribution, env); const persistence = new Persistence(this, "Persistence", { env,